Class: Cutter::Stamper
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
last, pop, push, scope
included
#colors, #colors?, #colors_config, #turn_colors
Constructor Details
#initialize(label) ⇒ Stamper
Returns a new instance of Stamper.
55
56
57
58
|
# File 'lib/cutter/stamper.rb', line 55
def initialize label
@label = label
@indent = 0
end
|
Instance Attribute Details
81
82
83
|
# File 'lib/cutter/stamper.rb', line 81
def indent
@indent ||= 0
end
|
Returns the value of attribute label.
49
50
51
|
# File 'lib/cutter/stamper.rb', line 49
def label
@label
end
|
#time_initial ⇒ Object
Returns the value of attribute time_initial.
50
51
52
|
# File 'lib/cutter/stamper.rb', line 50
def time_initial
@time_initial
end
|
Class Method Details
68
69
70
|
# File 'lib/cutter/stamper.rb', line 68
def self.loud!
self.turn :on
end
|
.off? ⇒ Boolean
77
78
79
|
# File 'lib/cutter/stamper.rb', line 77
def self.off?
!on?
end
|
.on? ⇒ Boolean
72
73
74
75
|
# File 'lib/cutter/stamper.rb', line 72
def self.on?
@@state ||= :on
@@state == :on
end
|
64
65
66
|
# File 'lib/cutter/stamper.rb', line 64
def self.quiet!
self.turn :off
end
|
.turn(state = :on) ⇒ Object
60
61
62
|
# File 'lib/cutter/stamper.rb', line 60
def self.turn state = :on
@@state = state
end
|
Instance Method Details
99
100
101
|
# File 'lib/cutter/stamper.rb', line 99
def [] key
messages[key]
end
|
95
96
97
|
# File 'lib/cutter/stamper.rb', line 95
def messages
@messages ||= {}
end
|
#msg(label) ⇒ Object
Also known as:
<<
89
90
91
|
# File 'lib/cutter/stamper.rb', line 89
def msg label
messages[label.keys.first] = label.values.first
end
|
85
86
87
|
# File 'lib/cutter/stamper.rb', line 85
def nindent
@indent +1
end
|
#stamp(lbl = nil) ⇒ Object
103
104
105
106
107
108
109
|
# File 'lib/cutter/stamper.rb', line 103
def stamp lbl = nil
return if Stamper.off?
message = messages[lbl] || lbl.to_s
time_passed = time_now - time_initial
print " " * nindent
printf("stamp: %7d ms #{message}\n", time_passed)
end
|