Class: PostRunner::DailySleepAnalyzer
- Inherits:
-
Object
- Object
- PostRunner::DailySleepAnalyzer
- Defined in:
- lib/postrunner/DailySleepAnalyzer.rb
Overview
This class extracts the sleep information from a set of monitoring files and determines when and how long the user was awake or had a light or deep sleep.
Defined Under Namespace
Classes: SleepInterval
Instance Attribute Summary collapse
-
#deep_sleep ⇒ Object
readonly
Returns the value of attribute deep_sleep.
-
#light_sleep ⇒ Object
readonly
Returns the value of attribute light_sleep.
-
#sleep_intervals ⇒ Object
readonly
Returns the value of attribute sleep_intervals.
-
#total_sleep ⇒ Object
readonly
Returns the value of attribute total_sleep.
-
#utc_offset ⇒ Object
readonly
Returns the value of attribute utc_offset.
Instance Method Summary collapse
-
#initialize(monitoring_files, day) ⇒ DailySleepAnalyzer
constructor
Create a new DailySleepAnalyzer object to analyze the given monitoring files.
Constructor Details
#initialize(monitoring_files, day) ⇒ DailySleepAnalyzer
Create a new DailySleepAnalyzer object to analyze the given monitoring files.
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/postrunner/DailySleepAnalyzer.rb', line 33 def initialize(monitoring_files, day) @noon_yesterday = @noon_today = @utc_offset = nil @sleep_intervals = [] # Day as Time object. Midnight UTC. day_as_time = Time.parse(day + "-00:00:00+00:00").gmtime extract_data_from_monitor_files(monitoring_files, day_as_time) fill_sleep_activity smoothen_sleep_activity analyze trim_wake_periods_at_ends calculate_totals end |
Instance Attribute Details
#deep_sleep ⇒ Object (readonly)
Returns the value of attribute deep_sleep.
26 27 28 |
# File 'lib/postrunner/DailySleepAnalyzer.rb', line 26 def deep_sleep @deep_sleep end |
#light_sleep ⇒ Object (readonly)
Returns the value of attribute light_sleep.
26 27 28 |
# File 'lib/postrunner/DailySleepAnalyzer.rb', line 26 def light_sleep @light_sleep end |
#sleep_intervals ⇒ Object (readonly)
Returns the value of attribute sleep_intervals.
26 27 28 |
# File 'lib/postrunner/DailySleepAnalyzer.rb', line 26 def sleep_intervals @sleep_intervals end |
#total_sleep ⇒ Object (readonly)
Returns the value of attribute total_sleep.
26 27 28 |
# File 'lib/postrunner/DailySleepAnalyzer.rb', line 26 def total_sleep @total_sleep end |
#utc_offset ⇒ Object (readonly)
Returns the value of attribute utc_offset.
26 27 28 |
# File 'lib/postrunner/DailySleepAnalyzer.rb', line 26 def utc_offset @utc_offset end |