Class: Vedeu::Key
- Inherits:
-
Object
- Object
- Vedeu::Key
- Defined in:
- lib/vedeu/input/key.rb
Overview
A single keypress or combination of keypresses bound to a specific action.
Instance Attribute Summary collapse
-
#input ⇒ String|Symbol
(also: #key)
readonly
Returns the key defined.
Instance Method Summary collapse
-
#initialize(input = nil, &block) ⇒ Key
constructor
Returns a new instance of Vedeu::Key.
-
#output ⇒ |Symbol
(also: #action, #press)
Pressing the key will call the procedure.
Constructor Details
#initialize(input = nil, &block) ⇒ Key
Returns a new instance of Vedeu::Key.
17 18 19 20 21 22 |
# File 'lib/vedeu/input/key.rb', line 17 def initialize(input = nil, &block) fail InvalidSyntax, 'block not given' unless block_given? @input = input @output = block end |
Instance Attribute Details
#input ⇒ String|Symbol (readonly) Also known as: key
Returns the key defined.
8 9 10 |
# File 'lib/vedeu/input/key.rb', line 8 def input @input end |
Instance Method Details
#output ⇒ |Symbol Also known as: action, press
Pressing the key will call the procedure.
27 28 29 |
# File 'lib/vedeu/input/key.rb', line 27 def output @output.call end |