Skip to content

Commit

Permalink
Make Chingu::Animation#[] accept Enumerables instead of just Ranges
Browse files Browse the repository at this point in the history
This way it's easy to extract a subanimation from non-consecutive, frames, like
this:

    @animation[(1..10).step(2)]
  • Loading branch information
Josep M. Bach committed Sep 18, 2013
1 parent 6245c7d commit 57962bc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/chingu/animation.rb
Expand Up @@ -174,7 +174,7 @@ def last_frame?
#
def [](index)
return @frames[index] if index.is_a?(Fixnum)
return self.new_from_frames(index) if index.is_a?(Range)
return self.new_from_frames(index) if index.respond_to?(:each)
return @sub_animations[index] if index.is_a?(Symbol)
end

Expand Down

0 comments on commit 57962bc

Please sign in to comment.