Class: Twstats::LogStats
- Inherits:
-
Object
- Object
- Twstats::LogStats
- Defined in:
- lib/twstats/descriptive_stats.rb
Instance Attribute Summary collapse
-
#logs ⇒ Object
readonly
Returns the value of attribute logs.
Instance Method Summary collapse
-
#initialize(logs) ⇒ LogStats
constructor
This class analyzes a give set of data and is used to extract information from times logged.
- #mean_log_time ⇒ Object
- #mean_task_time(tasks) ⇒ Object
Constructor Details
#initialize(logs) ⇒ LogStats
This class analyzes a give set of data and is used to extract information from times logged
6 7 8 |
# File 'lib/twstats/descriptive_stats.rb', line 6 def initialize(logs) @logs = logs end |
Instance Attribute Details
#logs ⇒ Object (readonly)
Returns the value of attribute logs.
4 5 6 |
# File 'lib/twstats/descriptive_stats.rb', line 4 def logs @logs end |
Instance Method Details
#mean_log_time ⇒ Object
10 11 12 13 |
# File 'lib/twstats/descriptive_stats.rb', line 10 def mean_log_time map = logs.map{|l| l.decimal_time} DescriptiveStatistics::Stats.new(map).mean end |
#mean_task_time(tasks) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/twstats/descriptive_stats.rb', line 15 def mean_task_time(tasks) time_per_task = [] tasks.each do |task| time_per_task << logs.select{|ll| ll.task == task}.inject(0){|sum, ll| sum + ll.decimal_time} end DescriptiveStatistics::Stats.new(time_per_task).mean end |