Skip to content

Commit

Permalink
refractor every_with_now to now_and_every
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommy Ong Gia Phu committed May 25, 2015
1 parent c445667 commit ab26b1b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -50,9 +50,9 @@ every_five_seconds = timers.every(5) { puts "Another 5 seconds" }
loop { timers.wait }
```

You also schedule a block to run immediately, and then periodically, with `Timers::Group#every_with_now`:
You also schedule a block to run immediately, and then periodically, with `Timers::Group#now_and_every`:
```ruby
every_with_now_and_five_seconds = timers.every_with_now(5) { puts "Now and another 5 seconds" }
now_and_every_five_seconds = timers.now_and_every(5) { puts "Now and another 5 seconds" }

loop { timer.wait }
```
Expand Down
2 changes: 1 addition & 1 deletion lib/timers/group.rb
Expand Up @@ -46,7 +46,7 @@ def every(interval, recur = true, &block)

# Call the given block immediately, and then periodically at the given interval. The first
# argument will be the time at which the group was asked to fire timers for.
def every_with_now(interval, recur = true, &block)
def now_and_every(interval, recur = true, &block)
block.call
every(interval, recur, &block)
end
Expand Down
4 changes: 2 additions & 2 deletions spec/every_spec.rb
Expand Up @@ -22,8 +22,8 @@

subject.every(0.7) { result << :a }
subject.every(2.3) { result << :b }
subject.every_with_now(1.3) { result << :c }
subject.every_with_now(2.4) { result << :d }
subject.now_and_every(1.3) { result << :c }
subject.now_and_every(2.4) { result << :d }

Timers::Wait.for(2.5) do |remaining|
subject.wait if subject.wait_interval < remaining
Expand Down

0 comments on commit ab26b1b

Please sign in to comment.