Class: Numbers
- Inherits:
-
Object
show all
- Defined in:
- lib/request_master/req_stats.rb
Instance Method Summary
collapse
Constructor Details
#initialize(array) ⇒ Numbers
Returns a new instance of Numbers.
14
15
16
|
# File 'lib/request_master/req_stats.rb', line 14
def initialize (array)
@array = array
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
18
19
20
|
# File 'lib/request_master/req_stats.rb', line 18
def method_missing (method, *args, &block)
@array.send(method, *args, &block)
end
|
Instance Method Details
#average ⇒ Object
26
27
28
|
# File 'lib/request_master/req_stats.rb', line 26
def average
sum.to_f / @array.size
end
|
#sum ⇒ Object
22
23
24
|
# File 'lib/request_master/req_stats.rb', line 22
def sum
@array.inject(0) { |acc, num| acc + num }
end
|