Class: Sunspot::Search::StatsRow
- Inherits:
-
Object
- Object
- Sunspot::Search::StatsRow
- Defined in:
- lib/sunspot/search/stats_row.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
- #instance ⇒ Object
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #count ⇒ Object
- #facet(name) ⇒ Object
- #facets ⇒ Object
-
#initialize(data, facet = nil, value = nil) ⇒ StatsRow
constructor
:nodoc:.
- #inspect ⇒ Object
- #max ⇒ Object
- #mean ⇒ Object
- #min ⇒ Object
- #missing ⇒ Object
- #standard_deviation ⇒ Object
- #sum ⇒ Object
- #sum_of_squares ⇒ Object
Constructor Details
#initialize(data, facet = nil, value = nil) ⇒ StatsRow
:nodoc:
7 8 9 10 |
# File 'lib/sunspot/search/stats_row.rb', line 7 def initialize(data, facet = nil, value = nil) #:nodoc: @data, @facet, @value = data, facet, value @facet_fields = [] end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
4 5 6 |
# File 'lib/sunspot/search/stats_row.rb', line 4 def data @data end |
#instance ⇒ Object
54 55 56 57 58 59 |
# File 'lib/sunspot/search/stats_row.rb', line 54 def instance if !defined?(@instance) @facet.populate_instances end @instance end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'lib/sunspot/search/stats_row.rb', line 4 def value @value end |
Instance Method Details
#count ⇒ Object
20 21 22 |
# File 'lib/sunspot/search/stats_row.rb', line 20 def count data['count'] end |
#facet(name) ⇒ Object
44 45 46 |
# File 'lib/sunspot/search/stats_row.rb', line 44 def facet name facets.find { |facet| facet.field.name == name.to_sym } end |
#facets ⇒ Object
48 49 50 51 52 |
# File 'lib/sunspot/search/stats_row.rb', line 48 def facets @facets ||= @facet_fields.map do |field| StatsFacet.new(field, data['facets'][field.indexed_name]) end end |
#inspect ⇒ Object
61 62 63 |
# File 'lib/sunspot/search/stats_row.rb', line 61 def inspect "<Sunspot::Search::StatsRow:#{value.inspect} min=#{min} max=#{max} count=#{count}>" end |
#max ⇒ Object
16 17 18 |
# File 'lib/sunspot/search/stats_row.rb', line 16 def max data['max'] end |
#mean ⇒ Object
36 37 38 |
# File 'lib/sunspot/search/stats_row.rb', line 36 def mean data['mean'] end |
#min ⇒ Object
12 13 14 |
# File 'lib/sunspot/search/stats_row.rb', line 12 def min data['min'] end |
#missing ⇒ Object
28 29 30 |
# File 'lib/sunspot/search/stats_row.rb', line 28 def missing data['missing'] end |
#standard_deviation ⇒ Object
40 41 42 |
# File 'lib/sunspot/search/stats_row.rb', line 40 def standard_deviation data['stddev'] end |
#sum ⇒ Object
24 25 26 |
# File 'lib/sunspot/search/stats_row.rb', line 24 def sum data['sum'] end |
#sum_of_squares ⇒ Object
32 33 34 |
# File 'lib/sunspot/search/stats_row.rb', line 32 def sum_of_squares data['sumOfSquares'] end |