Top Level Namespace
Defined Under Namespace
Classes: Livetext, LivetextAST, LivetextASTToHTML, Object, StringParser
Instance Method Summary collapse
- #checkpoint(msg = nil) ⇒ Object
-
#checkpoint!(msg = nil) ⇒ Object
with pause.
-
#checkpoint?(msg = nil) ⇒ Boolean
with sleep 3.
- #fatal(err) ⇒ Object
-
#make_exception(sym, str, target_class = Object) ⇒ Object
More later?.
- #warning(err) ⇒ Object
Instance Method Details
#checkpoint(msg = nil) ⇒ Object
12 13 14 15 16 |
# File 'lib/livetext/errors.rb', line 12 def checkpoint(msg = nil) return unless ENV['LIVETEXT_DEBUG'] == "true" file, line, meth = whence(1) display(file, line, meth, msg) end |
#checkpoint!(msg = nil) ⇒ Object
with pause
24 25 26 27 28 29 30 |
# File 'lib/livetext/errors.rb', line 24 def checkpoint!(msg = nil) # with pause return unless ENV['LIVETEXT_DEBUG'] == "true" file, line, meth = whence(1) display(file, line, meth, msg) print "::: Pause..." gets end |
#checkpoint?(msg = nil) ⇒ Boolean
with sleep 3
18 19 20 21 22 |
# File 'lib/livetext/errors.rb', line 18 def checkpoint?(msg = nil) # with sleep 3 return unless ENV['LIVETEXT_DEBUG'] == "true" file, line, meth = whence(1) display(file, line, meth, msg) end |
#fatal(err) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/livetext/errors.rb', line 40 def fatal(err) file, line, meth = whence(2) # 2 = skip rescue puts "Error in #{meth} in #{file}" puts "WTF??" puts " err = #{err.inspect}" if err.respond_to?(:backtrace) context = err.backtrace.map {|x| " " + x + "\n" } puts context end abort "Terminated." end |
#make_exception(sym, str, target_class = Object) ⇒ Object
More later?
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/livetext/errors.rb', line 55 def make_exception(sym, str, target_class = Object) return if target_class.constants.include?(sym) klass = sym # :"#{sym}_Class" target_class.const_set(klass, StandardError.dup) define_method(sym) do |*args| args = [] unless args.first msg = str.dup args.each.with_index {|arg, i| msg.sub!("%#{i+1}", arg.to_s) } target_class.class_eval(klass.to_s).new(msg) end end |
#warning(err) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/livetext/errors.rb', line 32 def warning(err) file, line, meth = whence(2) # 2 = skip rescue puts "Error in #{meth} in #{file} (non-fatal?)" puts " err = #{err.inspect}" puts " #{err.backtrace[0]}" if err.respond_to?(:backtrace) puts end |