Class: Sunspot::Search::StatsRow

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

Direct Known Subclasses

FieldStats

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dataObject (readonly)

Returns the value of attribute data.



4
5
6
# File 'lib/sunspot/search/stats_row.rb', line 4

def data
  @data
end

#instanceObject



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

#valueObject (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

#countObject



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

#facetsObject



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

#inspectObject



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

#maxObject



16
17
18
# File 'lib/sunspot/search/stats_row.rb', line 16

def max
  data['max']
end

#meanObject



36
37
38
# File 'lib/sunspot/search/stats_row.rb', line 36

def mean
  data['mean']
end

#minObject



12
13
14
# File 'lib/sunspot/search/stats_row.rb', line 12

def min
  data['min']
end

#missingObject



28
29
30
# File 'lib/sunspot/search/stats_row.rb', line 28

def missing
  data['missing']
end

#standard_deviationObject



40
41
42
# File 'lib/sunspot/search/stats_row.rb', line 40

def standard_deviation
  data['stddev']
end

#sumObject



24
25
26
# File 'lib/sunspot/search/stats_row.rb', line 24

def sum
  data['sum']
end

#sum_of_squaresObject



32
33
34
# File 'lib/sunspot/search/stats_row.rb', line 32

def sum_of_squares
  data['sumOfSquares']
end