Class: Sunspot::Search::StatsFacet

Inherits:
FieldFacet show all
Defined in:
lib/sunspot/search/stats_facet.rb

Instance Attribute Summary collapse

Attributes inherited from QueryFacet

#name

Instance Method Summary collapse

Methods inherited from FieldFacet

#field_name, #populate_instances

Methods inherited from QueryFacet

#add_row

Constructor Details

#initialize(field, data) ⇒ StatsFacet

:nodoc:



6
7
8
# File 'lib/sunspot/search/stats_facet.rb', line 6

def initialize(field, data) #:nodoc:
  @field, @data = field, data
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



4
5
6
# File 'lib/sunspot/search/stats_facet.rb', line 4

def field
  @field
end

Instance Method Details

#inspectObject



20
21
22
# File 'lib/sunspot/search/stats_facet.rb', line 20

def inspect
  "<Sunspot::Search::StatsFacet:#{@field}>"
end

#rows(options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/sunspot/search/stats_facet.rb', line 10

def rows(options = {})
  if options[:verified]
    verified_rows
  else
    @rows ||= @data.map do |value, data|
      StatsRow.new(data, self, @field.type.cast(value))
    end.sort_by { |row| row.value.to_s }
  end
end