Module: Plug::UI

Defined in:
lib/rbkb/plug/plug.rb

Constant Summary collapse

LOGCFG =
{:out => STDERR, :dump => :hex}

Class Method Summary collapse

Class Method Details

.debug(*msg) ⇒ Object



20
# File 'lib/rbkb/plug/plug.rb', line 20

def self.debug(*msg); LOGCFG[:out].puts msg if LOGCFG[:debug] ; end

.dump(from, to, dat) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rbkb/plug/plug.rb', line 22

def self.dump(from, to, dat)
  if dump=LOGCFG[:dump]
    LOGCFG[:out].puts "%% #{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
    LOGCFG[:out].puts "%%" if LOGCFG[:verbose]
  end
end

.log(*msg) ⇒ Object



16
# File 'lib/rbkb/plug/plug.rb', line 16

def self.log(*msg); LOGCFG[:out].puts msg ; end

.prompt(*msg) ⇒ Object



14
# File 'lib/rbkb/plug/plug.rb', line 14

def self.prompt(*msg); STDERR.puts msg ; STDIN.gets ; end

.verbose(*msg) ⇒ Object



18
# File 'lib/rbkb/plug/plug.rb', line 18

def self.verbose(*msg); LOGCFG[:out].puts msg if LOGCFG[:verbose] ; end