Class: SDL2::Joystick::Components
- Inherits:
-
Object
- Object
- SDL2::Joystick::Components
- Defined in:
- lib/sdl2/joystick/components.rb
Overview
Abstract component enumerator Requires :count and :[] to be defined
Instance Method Summary collapse
-
#each(&block) ⇒ Object
Generate enumerator, captures all at call time.
-
#initialize(for_joystick) ⇒ Components
constructor
Initialize an enumeration.
Constructor Details
#initialize(for_joystick) ⇒ Components
Initialize an enumeration
11 12 13 14 |
# File 'lib/sdl2/joystick/components.rb', line 11 def initialize(for_joystick) @joystick = for_joystick raise "Must be an SDL2::Joystick, not a #{@joystick.class.to_s}" unless @joystick.kind_of?(SDL2::Joystick) end |
Instance Method Details
#each(&block) ⇒ Object
Generate enumerator, captures all at call time
18 19 20 |
# File 'lib/sdl2/joystick/components.rb', line 18 def each(&block) count.times.map{|idx|self[idx]}.each(&block) end |