Class: Rubydraw::Events::KeyboardEvent
- Defined in:
- lib/rubydraw/events.rb
Overview
Provides methods used in both Rubydraw::Events::KeyPressed and Rubydraw::Events::KeyReleased. No instances of this class should be created, but instances of subclasses are fine.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(key) ⇒ KeyboardEvent
constructor
A new instance of KeyboardEvent.
Methods inherited from Event
#event?, matches?, matching_sdl_type
Constructor Details
#initialize(key) ⇒ KeyboardEvent
Returns a new instance of KeyboardEvent.
83 84 85 86 87 88 89 |
# File 'lib/rubydraw/events.rb', line 83 def initialize(key) unless key.is_a?(Numeric) raise SDLError "Failed to create new event because key is not a number." end @key = key end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
81 82 83 |
# File 'lib/rubydraw/events.rb', line 81 def key @key end |
Class Method Details
.from_sdl_event(sdl_event) ⇒ Object
77 78 79 |
# File 'lib/rubydraw/events.rb', line 77 def self.from_sdl_event(sdl_event) self.new(sdl_event.keysym.sym) end |
.wants_to_match? ⇒ Boolean
73 74 75 |
# File 'lib/rubydraw/events.rb', line 73 def self.wants_to_match? false end |