Class: Sunspot::Search::StatsFacet
- Inherits:
-
FieldFacet
- Object
- QueryFacet
- FieldFacet
- Sunspot::Search::StatsFacet
- Defined in:
- lib/sunspot/search/stats_facet.rb
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
Attributes inherited from QueryFacet
Instance Method Summary collapse
-
#initialize(field, data) ⇒ StatsFacet
constructor
:nodoc:.
- #inspect ⇒ Object
- #rows(options = {}) ⇒ Object
Methods inherited from FieldFacet
#field_name, #populate_instances
Methods inherited from QueryFacet
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
#field ⇒ Object (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
#inspect ⇒ Object
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( = {}) if [: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 |