Class: Bagel::Timeframe

Inherits:
Object
  • Object
show all
Defined in:
lib/bagel/timeframe.rb

Constant Summary collapse

SECONDS_IN_MINUTE =
60
SECONDS_IN_HOUR =
3600

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start, finish) ⇒ Timeframe

Returns a new instance of Timeframe.



8
9
10
11
# File 'lib/bagel/timeframe.rb', line 8

def initialize(start, finish)
  @start = start
  @finish = finish
end

Instance Attribute Details

#finishObject (readonly)

Returns the value of attribute finish.



3
4
5
# File 'lib/bagel/timeframe.rb', line 3

def finish
  @finish
end

#startObject (readonly)

Returns the value of attribute start.



3
4
5
# File 'lib/bagel/timeframe.rb', line 3

def start
  @start
end

Instance Method Details

#durationObject



13
14
15
# File 'lib/bagel/timeframe.rb', line 13

def duration
  seconds(finish) - seconds(start)
end

#duration_minutesObject



17
18
19
# File 'lib/bagel/timeframe.rb', line 17

def duration_minutes
  duration / SECONDS_IN_MINUTE
end