You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: facet_field_presenter.rb
    path of file: ./repos/blacklight/app/presenters/blacklight
    
    the code of the file until where you have to start completion: # frozen_string_lite
    
    def facet_limit
      return unless facet_field.limit

      if @display_facet
        limit = @display_facet.limit

        if limit.nil? # we didn't get or a set a limit, so infer one.
          facet_field.limit if facet_field.limit != true
        elsif limit == -1 # limit -1 is solr-speak for unlimited
          nil
        else
          limit.to_i - 1 # we added 1 to find out if we needed to paginate
        end