Class: GTK::Controller::Keys

Inherits:
Object
  • Object
show all
Includes:
Serialize
Defined in:
dragon/keys.rb

Constant Summary collapse

LABELS =
[
  :up, :down, :left, :right,
  :a, :b, :x, :y,
  :l1, :r1,
  :l2, :r2,
  :l3, :r3,
  :start, :select,
  :directional_up, :directional_down, :directional_left, :directional_right
].freeze

Instance Method Summary collapse

Instance Method Details

#activate(key) ⇒ void

This method returns an undefined value.

Activate a key.


28
29
30
# File 'dragon/keys.rb', line 28

def activate key
  instance_variable_set("@#{key}", Kernel.tick_count + 1)
end

#clearvoid

This method returns an undefined value.

Clear all key inputs.


42
43
44
# File 'dragon/keys.rb', line 42

def clear
  LABELS.each { |label| deactivate(label) }
end

#deactivate(key) ⇒ void

This method returns an undefined value.

Deactivate a key.


35
36
37
# File 'dragon/keys.rb', line 35

def deactivate key
  instance_variable_set("@#{key}", nil)
end

#truthy_keysObject


46
47
48
# File 'dragon/keys.rb', line 46

def truthy_keys
  LABELS.select { |label| send(label) }
end