Class: LCDProc::KeyEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/lcdproc/key_event.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, &block) ⇒ KeyEvent

Returns a new instance of KeyEvent.



52
53
54
55
# File 'lib/lcdproc/key_event.rb', line 52

def initialize( key, &block )
  @key = key
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



30
31
32
# File 'lib/lcdproc/key_event.rb', line 30

def block
  @block
end

#keyObject (readonly)

Returns the value of attribute key.



30
31
32
# File 'lib/lcdproc/key_event.rb', line 30

def key
  @key
end

Class Method Details

.new(key, &block) ⇒ Object

Creates a new KeyEvent object. Note that this does not register it with a client, it only gives you a clean object to pass around.

  • key - The key identifier. Valid values are “Escape”, “Enter”, “Up”, “Down”, “Left”, or “Right”.

  • &block - The block that you would like to associate with this key.

Example:

ke = KeyEvent.new( 'Enter' ) { puts 'Enter was pressed!' }


41
42
43
44
45
46
47
48
49
# File 'lib/lcdproc/key_event.rb', line 41

def self.new( key, &block )
  
  if block.nil?
    return nil
  else
    super( key, &block )
  end
  
end