Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/sane.rb
Instance Method Summary collapse
-
#_dbg ⇒ Object
helper to bring up a debugger for this to work in 1.9, please follow directions: wiki.github.com/mark-moseley/ruby-debug for 1.8, run gem install ruby-debug.
- #alias_h(hash) ⇒ Object
-
#assert(should_be_true, string = nil) ⇒ Object
ex: assert(some statement) or assert(some statement, “some helper string”).
-
#in?(collection) ⇒ Boolean
a helper for collection.include?.
-
#println(*args) ⇒ Object
a method like puts but all on one line–very much like java’s println, quite useful.
- #singleton_class ⇒ Object
Instance Method Details
#_dbg ⇒ Object
helper to bring up a debugger for this to work in 1.9, please follow directions: wiki.github.com/mark-moseley/ruby-debug for 1.8, run gem install ruby-debug
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/sane.rb', line 53 def _dbg require 'rubygems' require 'pp' # who would want debug without pp? not I begin require 'ruby-debug' debugger rescue LoadError => e throw "unable to load ruby-debug gem for _dbg... #{e}" end end |
#alias_h(hash) ⇒ Object
70 71 72 73 74 |
# File 'lib/sane.rb', line 70 def alias_h hash hash.each_pair {|new, old| alias_method new, old } end |
#assert(should_be_true, string = nil) ⇒ Object
ex: assert(some statement) or assert(some statement, “some helper string”)
44 45 46 47 48 |
# File 'lib/sane.rb', line 44 def assert(should_be_true, string = nil) if(!should_be_true) raise "assertion failed #{string}" end end |
#in?(collection) ⇒ Boolean
a helper for collection.include?
37 38 39 |
# File 'lib/sane.rb', line 37 def in? collection collection.include?(self) end |
#println(*args) ⇒ Object
a method like puts but all on one line–very much like java’s println, quite useful
65 66 67 68 |
# File 'lib/sane.rb', line 65 def println *args print *args puts end |
#singleton_class ⇒ Object
76 77 78 |
# File 'lib/sane.rb', line 76 def singleton_class class << self; self; end end |