class SDL2::Joystick::Components

Abstract component enumerator Requires :count and :[] to be defined

Public Class Methods

new(for_joystick) click to toggle source

Initialize an enumeration

# 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

Public Instance Methods

each(&block) click to toggle source

Generate enumerator, captures all at call time

# File lib/sdl2/joystick/components.rb, line 18
def each(&block)
  count.times.map{|idx|self[idx]}.each(&block)
end