Class: Vedeu::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) ⇒ Key

Returns a new instance of Vedeu::Key.

Parameters:

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

Raises:

  • (InvalidSyntax)

    The required block was not given.



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

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

Returns the key defined.

Returns:

  • (String|Symbol)

    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.

Returns:

  • (|Symbol)


27
28
29
# File 'lib/vedeu/input/key.rb', line 27

def output
  @output.call
end