Module: Timer
- Included in:
- Prick::Build::BuildBatch
- Defined in:
- lib/prick/local/timer.rb
Overview
TODO: Move class method implementations to Timer::Timer
Defined Under Namespace
Classes: Timer
Class Method Summary collapse
-
.file ⇒ Object
Output file used by #emit.
- .file=(file) ⇒ Object
- .new(*args) ⇒ Object
- .off! ⇒ Object
- .off? ⇒ Boolean
- .on! ⇒ Object
- .on? ⇒ Boolean
-
.scale ⇒ Object
Number of digits after the decimal point.
- .scale=(scale) ⇒ Object
- .time(label, &block) ⇒ Object
-
.unit ⇒ Object
Currently only :s, or :ms.
- .unit=(unit) ⇒ Object
Instance Method Summary collapse
Class Method Details
.file ⇒ Object
Output file used by #emit. Default is STDERR (this is set at load-time)
10 |
# File 'lib/prick/local/timer.rb', line 10 def self.file() @file end |
.file=(file) ⇒ Object
11 |
# File 'lib/prick/local/timer.rb', line 11 def self.file=(file) @file = file end |
.new(*args) ⇒ Object
34 35 36 37 38 |
# File 'lib/prick/local/timer.rb', line 34 def self.new(*args) object = Timer.allocate object.send(:initialize, *args) object end |
.off! ⇒ Object
5 |
# File 'lib/prick/local/timer.rb', line 5 def self.off!() @on = false end |
.off? ⇒ Boolean
7 |
# File 'lib/prick/local/timer.rb', line 7 def self.off?() !@on end |
.on! ⇒ Object
4 |
# File 'lib/prick/local/timer.rb', line 4 def self.on!() @on = true end |
.on? ⇒ Boolean
6 |
# File 'lib/prick/local/timer.rb', line 6 def self.on?() @on end |
.scale ⇒ Object
Number of digits after the decimal point. Default 0
18 |
# File 'lib/prick/local/timer.rb', line 18 def self.scale() @scale end |
.scale=(scale) ⇒ Object
19 |
# File 'lib/prick/local/timer.rb', line 19 def self.scale=(scale) @scale = scale end |
.time(label, &block) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/prick/local/timer.rb', line 21 def self.time(label, &block) if on? timer = Timer.new(label) r = yield timer.emit r else yield end end |
.unit ⇒ Object
Currently only :s, or :ms. Default is :ms
14 |
# File 'lib/prick/local/timer.rb', line 14 def self.unit() @unit end |
.unit=(unit) ⇒ Object
15 |
# File 'lib/prick/local/timer.rb', line 15 def self.unit=(unit) @unit = unit end |