Module: Vigilem::Evdev::ContextFilter
Defined Under Namespace
Modules: States
Constant Summary
Constants included
from States
States::OFF, States::ON, States::UNKNOWN
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#last_known_state ⇒ Object
Returns the value of attribute last_known_state.
37
38
39
|
# File 'lib/vigilem/evdev/context_filter.rb', line 37
def last_known_state
@last_known_state
end
|
Class Method Details
.included(base) ⇒ Object
33
34
35
|
# File 'lib/vigilem/evdev/context_filter.rb', line 33
def self.included(base)
base.extend Forwardable
end
|
Instance Method Details
#off? ⇒ Boolean
61
62
63
|
# File 'lib/vigilem/evdev/context_filter.rb', line 61
def off?
raise NotImplementedError, '#off?, not overriden'
end
|
#on? ⇒ Boolean
Also known as:
filtered?
53
54
55
|
# File 'lib/vigilem/evdev/context_filter.rb', line 53
def on?
raise NotImplementedError, '#on?, not overriden'
end
|
#on_change(state) ⇒ Object
68
69
70
71
72
|
# File 'lib/vigilem/evdev/context_filter.rb', line 68
def on_change(state)
self.last_known_state = state
changed
notify_observers(self, state)
end
|
#state_hash ⇒ Hash
23
24
25
26
27
|
# File 'lib/vigilem/evdev/context_filter.rb', line 23
def state_hash
@state_hash ||= States.constants.each_with_object({}) do |const, memo|
memo[States.const_get(const)] = const
end
end
|
#was_off? ⇒ TrueClass || FalseClass
47
48
49
|
# File 'lib/vigilem/evdev/context_filter.rb', line 47
def was_off?
last_known_state.nil? || last_known_state == OFF
end
|
#was_on? ⇒ TrueClass || FalseClass
41
42
43
|
# File 'lib/vigilem/evdev/context_filter.rb', line 41
def was_on?
last_known_state == ON
end
|