Skip to content
This repository has been archived by the owner on Oct 22, 2019. It is now read-only.

Commit

Permalink
No need to expose Simulator#current_month_index any more. Also using …
Browse files Browse the repository at this point in the history
…the range provided in Simulator#play seems more sensible.
  • Loading branch information
floehopper committed May 26, 2011
1 parent d5acc05 commit e6c0937
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions simulator.rb
@@ -1,5 +1,4 @@
class Simulator
attr_reader :current_month_index

def initialize
@events = Hash.new { |hash, key| hash[key] = [] }
Expand All @@ -10,7 +9,7 @@ def schedule_at(month_index, &block)
end

def schedule_in(number_of_months, &block)
schedule_at(current_month_index + number_of_months, &block)
schedule_at(@current_month_index + number_of_months, &block)
end

def schedule_each(month_offsets, &block)
Expand All @@ -20,8 +19,8 @@ def schedule_each(month_offsets, &block)
end

def play(month_range)
@current_month_index = month_range.first
while @current_month_index <= month_range.last do
month_range.each do |month_index|
@current_month_index = month_index
@events[@current_month_index].each do |event|
event.call(@current_month_index)
end
Expand Down

0 comments on commit e6c0937

Please sign in to comment.