Class: Rubydraw::Events::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/rubydraw/events.rb

Overview

The basic Event class. All events should inherit from this class, otherwise it won’t be recognized as an event and therefore will not participate in event matching.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_sdl_event(sdl_event) ⇒ Object

Just creates a new instance of this class by default. Override this if the subclass requires parameters in initialize, like Rubydraw::Events::MouseDown::from_sdl_event.



42
43
44
# File 'lib/rubydraw/events.rb', line 42

def self.from_sdl_event(sdl_event)
  self.new
end

.matches?(sdl_event) ⇒ Boolean

Returns true if this is the overlaying class for the given SDL event. Override this for custom matching.

Returns:

  • (Boolean)


48
49
50
# File 'lib/rubydraw/events.rb', line 48

def self.matches?(sdl_event)
  sdl_event.type == matching_sdl_type
end

.matching_sdl_typeObject

Returns the matching SDL event, override this in subclasses. Returns nil by default.



59
60
61
# File 'lib/rubydraw/events.rb', line 59

def self.matching_sdl_type
  nil
end

.wants_to_match?Boolean

Include the class for searching by default.

Returns:

  • (Boolean)


36
37
38
# File 'lib/rubydraw/events.rb', line 36

def self.wants_to_match?
  true
end

Instance Method Details

#event?Boolean

Returns true for all event objects. Also see Object#event?

Returns:

  • (Boolean)


53
54
55
# File 'lib/rubydraw/events.rb', line 53

def event?
  true
end