Class: Sunspot::FacetData::FieldFacetData
- Defined in:
- lib/sunspot/facet_data.rb
Overview
FieldFacetData encapsulates the data returned by field facets
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Abstract
Instance Method Summary collapse
-
#initialize(facet_values, field) ⇒ FieldFacetData
constructor
A new instance of FieldFacetData.
-
#name ⇒ Object
The name of the field that contains this facet’s values.
-
#rows ⇒ Object
The rows returned for this facet.
Methods inherited from Abstract
Constructor Details
#initialize(facet_values, field) ⇒ FieldFacetData
Returns a new instance of FieldFacetData.
48 49 50 |
# File 'lib/sunspot/facet_data.rb', line 48 def initialize(facet_values, field) @facet_values, @field = facet_values, field end |
Instance Method Details
#name ⇒ Object
The name of the field that contains this facet’s values
Returns
- Symbol
-
The field name
58 59 60 |
# File 'lib/sunspot/facet_data.rb', line 58 def name @field.name end |
#rows ⇒ Object
The rows returned for this facet.
Returns
- Array
-
Collection of FacetRow objects, in the order returned by Solr
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/sunspot/facet_data.rb', line 68 def rows @rows ||= begin rows = [] @facet_values.each_slice(2) do |value, count| rows << yield(row_value(value), count) end rows end end |