Class: Vedeu::Input::Key

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/input/key.rb

Overview

A single keypress or combination of keypresses bound to a specific action.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input = nil, &block) ⇒ Vedeu::Input::Key

Returns a new instance of Vedeu::Input::Key.

Raises:



22
23
24
25
26
27
# File 'lib/vedeu/input/key.rb', line 22

def initialize(input = nil, &block)
  fail Vedeu::Error::InvalidSyntax, 'block not given' unless block_given?

  @input  = input
  @output = block
end

Instance Attribute Details

#inputString|Symbol (readonly) Also known as: key



12
13
14
# File 'lib/vedeu/input/key.rb', line 12

def input
  @input
end

Instance Method Details

#output|Symbol Also known as: action, press

Pressing the key will call the procedure.



32
33
34
# File 'lib/vedeu/input/key.rb', line 32

def output
  @output.call
end