Class: TimeBuffer::StateDetector
- Inherits:
-
Object
- Object
- TimeBuffer::StateDetector
- Defined in:
- lib/time_buffer/state_detector.rb
Instance Attribute Summary collapse
-
#current_app_data ⇒ Object
readonly
Returns the value of attribute current_app_data.
-
#last_interaction_at ⇒ Object
readonly
Returns the value of attribute last_interaction_at.
-
#previous_app ⇒ Object
readonly
Returns the value of attribute previous_app.
-
#previous_metadata ⇒ Object
readonly
Returns the value of attribute previous_metadata.
Instance Method Summary collapse
- #app_changed? ⇒ Boolean
-
#initialize ⇒ StateDetector
constructor
A new instance of StateDetector.
- #metadata_changed? ⇒ Boolean
- #update_last_interaction_time(now) ⇒ Object
Constructor Details
#initialize ⇒ StateDetector
7 8 9 10 11 12 |
# File 'lib/time_buffer/state_detector.rb', line 7 def initialize @previous_app = nil = {} @last_interaction_at = Time.now @current_app_data = nil end |
Instance Attribute Details
#current_app_data ⇒ Object (readonly)
Returns the value of attribute current_app_data.
5 6 7 |
# File 'lib/time_buffer/state_detector.rb', line 5 def current_app_data @current_app_data end |
#last_interaction_at ⇒ Object (readonly)
Returns the value of attribute last_interaction_at.
5 6 7 |
# File 'lib/time_buffer/state_detector.rb', line 5 def last_interaction_at @last_interaction_at end |
#previous_app ⇒ Object (readonly)
Returns the value of attribute previous_app.
5 6 7 |
# File 'lib/time_buffer/state_detector.rb', line 5 def previous_app @previous_app end |
#previous_metadata ⇒ Object (readonly)
Returns the value of attribute previous_metadata.
5 6 7 |
# File 'lib/time_buffer/state_detector.rb', line 5 def end |
Instance Method Details
#app_changed? ⇒ Boolean
14 15 16 17 |
# File 'lib/time_buffer/state_detector.rb', line 14 def app_changed? @current_app_data = OsaScript.app_data @current_app_data.name != @previous_app end |
#metadata_changed? ⇒ Boolean
19 20 21 22 |
# File 'lib/time_buffer/state_detector.rb', line 19 def = current_app_data. && != && current_app_data.name == previous_app end |
#update_last_interaction_time(now) ⇒ Object
24 25 26 27 |
# File 'lib/time_buffer/state_detector.rb', line 24 def update_last_interaction_time(now) @last_interaction_at = now update_state end |