Class: Orchestrate::Search::StatsResult
- Inherits:
-
AggregateResult
- Object
- AggregateResult
- Orchestrate::Search::StatsResult
- Defined in:
- lib/orchestrate/search/results.rb
Overview
Stats Aggregate result object
Instance Attribute Summary collapse
-
#max ⇒ Float
readonly
Highest numerical value of the statistics result.
-
#mean ⇒ Float
readonly
Average of included numerical values.
-
#min ⇒ Float
readonly
Lowest numerical value of the statistics result.
-
#statistics ⇒ Hash
readonly
The statistics results.
- #std_dev ⇒ Float readonly
-
#sum ⇒ Float
readonly
Total of included numerical values.
- #sum_of_squares ⇒ Float readonly
- #variance ⇒ Float readonly
Attributes inherited from AggregateResult
#collection, #count, #field_name, #kind
Instance Method Summary collapse
-
#initialize(collection, listing) ⇒ StatsResult
constructor
Initialize a new StatsResult object.
-
#to_s ⇒ Object
(also: #inspect)
Pretty-Printed string representation of the StatsResult object.
Constructor Details
#initialize(collection, listing) ⇒ StatsResult
Initialize a new StatsResult object
153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/orchestrate/search/results.rb', line 153 def initialize(collection, listing) super(collection, listing) if listing['statistics'] @statistics = listing['statistics'] @min = @statistics['min'] @max = @statistics['max'] @mean = @statistics['mean'] @sum = @statistics['sum'] @sum_of_squares = @statistics['sum_of_squares'] @variance = @statistics['variance'] @std_dev = @statistics['std_dev'] end end |
Instance Attribute Details
#max ⇒ Float (readonly)
Returns Highest numerical value of the statistics result.
133 134 135 |
# File 'lib/orchestrate/search/results.rb', line 133 def max @max end |
#mean ⇒ Float (readonly)
Returns Average of included numerical values.
136 137 138 |
# File 'lib/orchestrate/search/results.rb', line 136 def mean @mean end |
#min ⇒ Float (readonly)
Returns Lowest numerical value of the statistics result.
130 131 132 |
# File 'lib/orchestrate/search/results.rb', line 130 def min @min end |
#statistics ⇒ Hash (readonly)
Returns The statistics results.
127 128 129 |
# File 'lib/orchestrate/search/results.rb', line 127 def statistics @statistics end |
#std_dev ⇒ Float (readonly)
148 149 150 |
# File 'lib/orchestrate/search/results.rb', line 148 def std_dev @std_dev end |
#sum ⇒ Float (readonly)
Returns Total of included numerical values.
139 140 141 |
# File 'lib/orchestrate/search/results.rb', line 139 def sum @sum end |
#sum_of_squares ⇒ Float (readonly)
142 143 144 |
# File 'lib/orchestrate/search/results.rb', line 142 def sum_of_squares @sum_of_squares end |
#variance ⇒ Float (readonly)
145 146 147 |
# File 'lib/orchestrate/search/results.rb', line 145 def variance @variance end |
Instance Method Details
#to_s ⇒ Object Also known as: inspect
Returns Pretty-Printed string representation of the StatsResult object.
168 169 170 171 |
# File 'lib/orchestrate/search/results.rb', line 168 def to_s stats = "statistics={\n min=#{min},\n max=#{max},\n mean=#{mean},\n sum=#{sum},\n sum_of_squares=#{sum_of_squares},\n variance=#{variance},\n std_dev=#{std_dev}\n}" "#<Orchestrate::Search::StatsResult collection=#{collection.name} field_name=#{field_name} count=#{count} #{stats}>" end |