Top Level Namespace

Defined Under Namespace

Modules: RubyText, WindowIO

Constant Summary collapse

Colors =
[Black, Blue, Cyan, Green, Magenta, Red, White, Yellow]
X =

shorthand

Curses

Instance Method Summary collapse

Instance Method Details

#debug(*args) ⇒ Object



55
56
57
58
59
# File 'lib/rubytext.rb', line 55

def debug(*args)
  return unless $debug
  $debug.puts *args
  $debug.flush
end

#import(meth, recv) ⇒ Object



36
37
38
39
40
# File 'lib/rubytext.rb', line 36

def import(meth, recv)
  Kernel.module_eval do
    define_method(meth) {|*args| recv.send(meth, *args) }
  end
end

#make_exception(sym, str) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/rubytext.rb', line 42

def make_exception(sym, str)
  return if Object.constants.include?(sym)
  Object.const_set(sym, StandardError.dup)
  define_method(sym) do |*args|
    msg = str
    list = (args + [nil]*2)[0..2]
    list.each.with_index {|arg, i| msg.sub!("$#{i+1}", arg) }
    Object.class_eval(sym.to_s).new(msg)
  end
end