Module: Vigilem::Evdev::ContextFilter

Includes:
Observable, States
Included in:
FocusContextFilter, VTYContextFilter
Defined in:
lib/vigilem/evdev/context_filter.rb

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_stateObject

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

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


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?

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


53
54
55
# File 'lib/vigilem/evdev/context_filter.rb', line 53

def on?
  raise NotImplementedError, '#on?, not overriden'
end

#on_change(state) ⇒ Object

Parameters:

  • state (Fixnum<1 || 0>)

Returns:



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_hashHash

Returns:

  • (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

Returns:

  • (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

Returns:

  • (TrueClass || FalseClass)


41
42
43
# File 'lib/vigilem/evdev/context_filter.rb', line 41

def was_on?
  last_known_state == ON
end