Class: TimeBuffer::StateDetector

Inherits:
Object
  • Object
show all
Defined in:
lib/time_buffer/state_detector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStateDetector



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_dataObject (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_atObject (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_appObject (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_metadataObject (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