class Cutter::Stamper

Attributes

indent[W]
label[R]
time_initial[RW]

Public Class Methods

loud!() click to toggle source
# File lib/cutter/stamper.rb, line 96
def self.loud!
  self.turn :on
end
new(label) click to toggle source
# File lib/cutter/stamper.rb, line 83
def initialize label
  @label = label
  @indent = 0
end
off?() click to toggle source
# File lib/cutter/stamper.rb, line 105
def self.off?
  !on?
end
on?() click to toggle source
# File lib/cutter/stamper.rb, line 100
def self.on?
  @@state ||= :on
  @@state == :on
end
quiet!() click to toggle source
# File lib/cutter/stamper.rb, line 92
def self.quiet!
  self.turn :off
end
turn(state = :on) click to toggle source
# File lib/cutter/stamper.rb, line 88
def self.turn state = :on
  @@state = state
end

Public Instance Methods

<<(label)
Alias for: msg
[](key) click to toggle source
# File lib/cutter/stamper.rb, line 127
def [] key
  messages[key]
end
indent() click to toggle source
# File lib/cutter/stamper.rb, line 109
def indent
  @indent ||= 0
end
messages() click to toggle source
# File lib/cutter/stamper.rb, line 123
def messages
  @messages ||= {}
end
msg(label) click to toggle source
# File lib/cutter/stamper.rb, line 117
def msg label
  messages[label.keys.first] = label.values.first
end
Also aliased as: <<
nindent() click to toggle source
# File lib/cutter/stamper.rb, line 113
def nindent
  @indent +1
end
stamp(lbl = nil) click to toggle source
# File lib/cutter/stamper.rb, line 131
def stamp lbl = nil
  return if Stamper.off?
  message = messages[lbl] || lbl.to_s
  time_passed = Time.now.ms_since time_initial
  print "  " * nindent
  printf("stamp: %7dms   #{message}\n", time_passed)
end
Also aliased as: stamp!
stamp!(lbl = nil)
Alias for: stamp