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 Method Summary collapse

Constructor Details

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

Returns a new instance of Key.

Parameters:

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

Raises:

  • (InvalidSyntax)

    The required block was not given.



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

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

  @input  = input
  @output = block
end

Instance Method Details

#inputString|Symbol Also known as: key

Returns the key defined.

Returns:

  • (String|Symbol)


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

def input
  @input
end

#output|Symbol Also known as: action, press

Pressing the key will call the procedure.

Returns:

  • (|Symbol)


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

def output
  @output.call
end