Class: Sunspot::Search::JsonFacetStats

Inherits:
Object
  • Object
show all
Defined in:
lib/sunspot/search/json_facet_stats.rb

Instance Method Summary collapse

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, options)
  @field, @search, @options = field, search, options
end

Instance Method Details

#rowsObject



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