class Bagel::Timeframe

Constants

SECONDS_IN_HOUR
SECONDS_IN_MINUTE

Attributes

finish[R]
start[R]

Public Class Methods

new(start, finish) click to toggle source
# File lib/bagel/timeframe.rb, line 8
def initialize(start, finish)
  @start = start
  @finish = finish
end

Public Instance Methods

duration() click to toggle source
# File lib/bagel/timeframe.rb, line 13
def duration
  seconds(finish) - seconds(start)
end
duration_minutes() click to toggle source
# File lib/bagel/timeframe.rb, line 17
def duration_minutes
  duration / SECONDS_IN_MINUTE
end

Private Instance Methods

seconds(timestamp) click to toggle source
# File lib/bagel/timeframe.rb, line 23
def seconds(timestamp)
  parts = timestamp.split(':')
  s = parts.pop
  m = parts.pop
  h = parts.pop
  (h.to_i * SECONDS_IN_HOUR) + (m.to_i * SECONDS_IN_MINUTE) + s.to_i
end