Skip to content

Commit

Permalink
Stack now implements Enuberable
Browse files Browse the repository at this point in the history
  • Loading branch information
pmatsinopoulos committed Feb 12, 2012
1 parent c2e0776 commit c2ea926
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions models/stack.rb
@@ -1,10 +1,13 @@
class Stack
include Enumerable

# public methods
def initialize
@stack = Array.new
end

attr_reader :stack

def push(element)
@stack << element
end
Expand All @@ -27,4 +30,8 @@ def empty?
@stack.size == 0
end

def each(&block)
@stack.each(&block)
end

end

0 comments on commit c2ea926

Please sign in to comment.