Class: Sunspot::Search::JsonFacetStats
- Inherits:
-
Object
- Object
- Sunspot::Search::JsonFacetStats
- Defined in:
- lib/sunspot/search/json_facet_stats.rb
Instance Method Summary collapse
-
#initialize(field, search, options) ⇒ JsonFacetStats
constructor
A new instance of JsonFacetStats.
- #rows ⇒ Object
Constructor Details
#initialize(field, search, options) ⇒ JsonFacetStats
Returns a new instance of JsonFacetStats.
4 5 6 |
# File 'lib/sunspot/search/json_facet_stats.rb', line 4 def initialize(field, search, ) @field, @search, @options = field, search, end |
Instance Method Details
#rows ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/sunspot/search/json_facet_stats.rb', line 8 def rows @rows ||= begin json_facet_response = @search.json_facet_response[@field.to_s] data = json_facet_response.nil? ? [] : json_facet_response['buckets'] rows = [] data.each do |d| rows << StatsJsonRow.new(d, nil, d['val']) end rows end end |