Class: Blackbeard::MetricHour

Inherits:
Object
  • Object
show all
Defined in:
lib/blackbeard/metric_hour.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time, result) ⇒ MetricHour

Returns a new instance of MetricHour.



5
6
7
8
# File 'lib/blackbeard/metric_hour.rb', line 5

def initialize(time, result)
  @hour = round_to_beginning_of_hour(time)
  @result = result
end

Instance Attribute Details

#hourObject (readonly)

Returns the value of attribute hour.



3
4
5
# File 'lib/blackbeard/metric_hour.rb', line 3

def hour
  @hour
end

#resultObject (readonly)

Returns the value of attribute result.



3
4
5
# File 'lib/blackbeard/metric_hour.rb', line 3

def result
  @result
end

Instance Method Details

#result_rows(segments) ⇒ Object



14
15
16
# File 'lib/blackbeard/metric_hour.rb', line 14

def result_rows(segments)
  [@hour.strftime("%l%P")] + results_for(segments)
end

#results_for(segments) ⇒ Object



10
11
12
# File 'lib/blackbeard/metric_hour.rb', line 10

def results_for(segments)
  segments.map{|s| result[s].to_f }
end