Module: Plug::UI
- Defined in:
- lib/rbkb/plug/plug.rb
Constant Summary collapse
- LOGCFG =
{ out: STDERR, dump: :hex }
Class Method Summary collapse
- .debug(*msg) ⇒ Object
- .dump(from, to, dat) ⇒ Object
- .log(*msg) ⇒ Object
- .logmsg(name, msg) ⇒ Object
- .prompt(*msg) ⇒ Object
- .verbose(*msg) ⇒ Object
Class Method Details
.debug(*msg) ⇒ Object
26 27 28 |
# File 'lib/rbkb/plug/plug.rb', line 26 def self.debug(*msg) LOGCFG[:out].puts msg if LOGCFG[:debug] end |
.dump(from, to, dat) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rbkb/plug/plug.rb', line 34 def self.dump(from, to, dat) return unless dump = LOGCFG[:dump] log "%% #{from} SAYS TO #{to} LEN=#{dat.size}" if LOGCFG[:verbose] case dump when :hex dat.hexdump(out: LOGCFG[:out]) when :raw LOGCFG[:out].puts dat else LOGCFG[:out].puts dat end log '%%' if LOGCFG[:verbose] end |
.log(*msg) ⇒ Object
18 19 20 |
# File 'lib/rbkb/plug/plug.rb', line 18 def self.log(*msg) LOGCFG[:out].puts msg end |
.logmsg(name, msg) ⇒ Object
30 31 32 |
# File 'lib/rbkb/plug/plug.rb', line 30 def self.logmsg(name, msg) log "%% #{name} - #{msg}" end |
.prompt(*msg) ⇒ Object
13 14 15 16 |
# File 'lib/rbkb/plug/plug.rb', line 13 def self.prompt(*msg) warn msg STDIN.gets end |