]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/rspec-1.1.2/examples/stories/adder.rb
added RSpec and RSpec on Rails
[rails.git] / vendor / gems / rspec-1.1.2 / examples / stories / adder.rb
1 class Adder
2   def initialize
3     @addends = []
4   end
5   
6   def <<(val)
7     @addends << val
8   end
9   
10   def sum
11     @addends.inject(0) { |sum_so_far, val| sum_so_far + val }
12   end
13 end