Class: PostRunner::SleepPhase

Inherits:
Object
  • Object
show all
Defined in:
lib/postrunner/SleepCycle.rb

Overview

A SleepPhase is a segment of a sleep cycle. It captures the start and end time as well as the kind of phase.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from_time, to_time, phase) ⇒ SleepPhase

Create a new sleep phase.

Parameters:

  • from_time (Time)

    Start time of the phase

  • to_time (Time)

    End time of the phase

  • phase (Symbol)

    The kind of phase [ :rem, :nrem1, :nrem2, :nrem3 ]



25
26
27
28
29
# File 'lib/postrunner/SleepCycle.rb', line 25

def initialize(from_time, to_time, phase)
  @from_time = from_time
  @to_time = to_time
  @phase = phase
end

Instance Attribute Details

#from_timeObject (readonly)

Returns the value of attribute from_time.



19
20
21
# File 'lib/postrunner/SleepCycle.rb', line 19

def from_time
  @from_time
end

#phaseObject (readonly)

Returns the value of attribute phase.



19
20
21
# File 'lib/postrunner/SleepCycle.rb', line 19

def phase
  @phase
end

#to_timeObject (readonly)

Returns the value of attribute to_time.



19
20
21
# File 'lib/postrunner/SleepCycle.rb', line 19

def to_time
  @to_time
end

Instance Method Details

#durationFixnum

Duration of the phase in seconds.

Returns:

  • (Fixnum)

    duration



33
34
35
# File 'lib/postrunner/SleepCycle.rb', line 33

def duration
  @to_time - @from_time
end