Class: AniRuby::Frames

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/aniruby/frames.rb

Overview

Collection of frames

Instance Method Summary collapse

Constructor Details

#initialize(sprites) ⇒ Frames

Create a new collection of frames

Parameters:

  • sprites (Array<Gosu::Image>)


9
10
11
12
13
# File 'lib/aniruby/frames.rb', line 9

def initialize(sprites)
  @frames = sprites.map do |sprite|
    AniRuby::Frame.new(sprite)
  end
end

Instance Method Details

#[](index) ⇒ Frame

Parameters:

  • index (Integer)

Returns:



18
19
20
# File 'lib/aniruby/frames.rb', line 18

def [](index)
  @frames[index]
end

#each(&block) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/aniruby/frames.rb', line 22

def each(&block)
  @frames.each do |frame|
    if block_given?
      block.call(frame)
    else
      yield frame
    end
  end
end