Sha256: 2ddd1b764ec2de6869bb0972c615eb1d97b7998ef65ef2ff6684c16da1c7e34a

Contents?: true

Size: 916 Bytes

Versions: 13

Compression:

Stored size: 916 Bytes

Contents

module Sunspot
  # This class encapsulates a facet row (value) for a facet.
  class FacetRow
    def initialize(facet_value, field) #:nodoc:
      @facet_value, @field = facet_value, field
    end

    # The value associated with the facet. This will be cast according to the
    # field's type; so, for an integer field, this method will return an
    # integer, etc.
    #
    # Note that <strong>+Time+ fields will always return facet values in
    # UTC</strong>.
    #
    # ==== Returns
    #
    # Object:: The value associated with the row, cast to the appropriate type
    #
    def value
      @value ||= @field.cast(@facet_value.name)
    end

    # The number of documents matching the search parameters that have this
    # value in the facet's field.
    #
    # ==== Returns
    #
    # Integer:: Document count for this value
    #
    def count
      @count ||= @facet_value.value
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
outoftime-sunspot-0.7.0 lib/sunspot/facet_row.rb
outoftime-sunspot-0.7.1 lib/sunspot/facet_row.rb
outoftime-sunspot-0.7.2 lib/sunspot/facet_row.rb
outoftime-sunspot-0.7.3 lib/sunspot/facet_row.rb
outoftime-sunspot-0.8.0 lib/sunspot/facet_row.rb
outoftime-sunspot-0.8.1 lib/sunspot/facet_row.rb
outoftime-sunspot-0.8.2 lib/sunspot/facet_row.rb
outoftime-sunspot-0.8.3 lib/sunspot/facet_row.rb
outoftime-sunspot-0.8.4 lib/sunspot/facet_row.rb
outoftime-sunspot-0.8.5 lib/sunspot/facet_row.rb
outoftime-sunspot-0.8.8 lib/sunspot/facet_row.rb
outoftime-sunspot-0.8.9 lib/sunspot/facet_row.rb
pallan-sunspot-0.8.3 lib/sunspot/facet_row.rb