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.

Parameters:

  • input (String|Symbol) (defaults to: nil)
  • block (Proc)

Raises:



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

def initialize(input = nil, &block)
  raise Vedeu::Error::RequiresBlock unless block_given?

  @input  = input
  @output = block
end

Instance Attribute Details

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

Returns the key defined.

Returns:

  • (String|Symbol)

    Returns the key defined.



14
15
16
# File 'lib/vedeu/input/key.rb', line 14

def input
  @input
end

Instance Method Details

#output|Symbol Also known as: action, press

Pressing the key will call the procedure.

Returns:

  • (|Symbol)


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

def output
  @output.call
end