timers 1.0.0.pre3 → 1.0.0.pre4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/timers.rb +6 -6
  2. data/lib/timers/version.rb +1 -1
  3. metadata +5 -5
data/lib/timers.rb CHANGED
@@ -23,22 +23,22 @@ class Timers
23
23
 
24
24
  # Wait for the next timer and fire it
25
25
  def wait
26
- return if empty?
27
- sleep wait_interval
26
+ i = wait_interval
27
+ sleep i if i
28
28
  fire
29
29
  end
30
30
 
31
31
  # Interval to wait until when the next timer will fire
32
32
  def wait_interval(now = Time.now)
33
- return if empty?
34
- @timers.first.time - now
33
+ timer = @timers.first
34
+ return unless timer
35
+ timer.time - now
35
36
  end
36
37
 
37
38
  # Fire all timers that are ready
38
39
  def fire(now = Time.now)
39
40
  time = now + 0.001 # Fudge 1ms in case of clock imprecision
40
- while !empty? && time >= @timers.first.time
41
- timer = @timers.first
41
+ while (timer = @timers.first) && (time >= timer.time)
42
42
  @timers.delete timer
43
43
  timer.fire(now)
44
44
  end
@@ -1,3 +1,3 @@
1
1
  class Timers
2
- VERSION = "1.0.0.pre3"
2
+ VERSION = "1.0.0.pre4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre3
4
+ version: 1.0.0.pre4
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-07-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70219648395780 !ruby/object:Gem::Requirement
16
+ requirement: &70124148288040 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70219648395780
24
+ version_requirements: *70124148288040
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70219648395360 !ruby/object:Gem::Requirement
27
+ requirement: &70124148287620 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70219648395360
35
+ version_requirements: *70124148287620
36
36
  description: Pure Ruby one-shot and periodic timers
37
37
  email:
38
38
  - tony.arcieri@gmail.com