Class: Neotrellis::Keypad::KeyEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/neotrellis/keypad.rb

Overview

Represent an event attached to a key

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, edge) ⇒ KeyEvent

Create a new event.

Parameters:



190
191
192
193
# File 'lib/neotrellis/keypad.rb', line 190

def initialize(key, edge)
	@key = key
	@edge = edge
end

Instance Attribute Details

#edgeObject (readonly)

Event type



184
185
186
# File 'lib/neotrellis/keypad.rb', line 184

def edge
  @edge
end

#keyObject (readonly)

Key ID



183
184
185
# File 'lib/neotrellis/keypad.rb', line 183

def key
  @key
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



199
200
201
# File 'lib/neotrellis/keypad.rb', line 199

def ==(other)
	@key == other.key && @edge == other.edge
end

#hashObject



205
206
207
# File 'lib/neotrellis/keypad.rb', line 205

def hash
	@key.hash ^ @edge.hash # XOR
end

#to_sObject



195
196
197
# File 'lib/neotrellis/keypad.rb', line 195

def to_s
	"Event-#{key}-#{edge}"
end