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.
67
68
69
70
|
# File 'lib/cutter/stamper.rb', line 67
def initialize label
@label = label
@indent = 0
end
|
Instance Attribute Details
93
94
95
|
# File 'lib/cutter/stamper.rb', line 93
def indent
@indent ||= 0
end
|
Returns the value of attribute label.
61
62
63
|
# File 'lib/cutter/stamper.rb', line 61
def label
@label
end
|
#time_initial ⇒ Object
Returns the value of attribute time_initial.
62
63
64
|
# File 'lib/cutter/stamper.rb', line 62
def time_initial
@time_initial
end
|
Class Method Details
80
81
82
|
# File 'lib/cutter/stamper.rb', line 80
def self.loud!
self.turn :on
end
|
.off? ⇒ Boolean
89
90
91
|
# File 'lib/cutter/stamper.rb', line 89
def self.off?
!on?
end
|
.on? ⇒ Boolean
84
85
86
87
|
# File 'lib/cutter/stamper.rb', line 84
def self.on?
@@state ||= :on
@@state == :on
end
|
76
77
78
|
# File 'lib/cutter/stamper.rb', line 76
def self.quiet!
self.turn :off
end
|
.turn(state = :on) ⇒ Object
72
73
74
|
# File 'lib/cutter/stamper.rb', line 72
def self.turn state = :on
@@state = state
end
|
Instance Method Details
111
112
113
|
# File 'lib/cutter/stamper.rb', line 111
def [] key
messages[key]
end
|
107
108
109
|
# File 'lib/cutter/stamper.rb', line 107
def messages
@messages ||= {}
end
|
#msg(label) ⇒ Object
Also known as:
<<
101
102
103
|
# File 'lib/cutter/stamper.rb', line 101
def msg label
messages[label.keys.first] = label.values.first
end
|
97
98
99
|
# File 'lib/cutter/stamper.rb', line 97
def nindent
@indent +1
end
|
#stamp(lbl = nil) ⇒ Object
Also known as:
stamp!
115
116
117
118
119
120
121
|
# File 'lib/cutter/stamper.rb', line 115
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
|