Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/sane/sane_random.rb,
lib/sane/pps.rb,
lib/sane/try2.rb,
lib/sane/present.rb,
lib/sane/test/assertions.rb
Overview
more helpers
Instance Method Summary collapse
-
#_dbg ⇒ Object
helper to bring up a debugger with less writing [just _dbg].
-
#assert(should_be_true, string = nil) ⇒ Object
(also: #y!, #yes!)
ex: assert(some statement) or assert(some statement, “some helper string”).
-
#in?(collection) ⇒ Boolean
a helper for collection.include?.
-
#pps(*args) ⇒ Object
a method that outputs several items on one line similar to using pp, this space separates the items passed in and writes them to one line sputs 1,2,3 => 1 2 3.
- #present? ⇒ Boolean
- #refute(this_boolean, string = nil) ⇒ Object
- #singleton_class ⇒ Object
- #try2 ⇒ Object
Instance Method Details
#_dbg ⇒ Object
helper to bring up a debugger with less writing [just _dbg]
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/sane/sane_random.rb', line 39 def _dbg begin require 'ruby-debug' debugger rescue LoadError => e require 'rubygems' begin require 'ruby-debug' rescue LoadError => e throw "unable to load ruby-debug gem for _dbg... #{e}" end end end |
#assert(should_be_true, string = nil) ⇒ Object Also known as: y!, yes!
ex: assert(some statement) or assert(some statement, “some helper string”)
8 9 10 11 12 |
# File 'lib/sane/test/assertions.rb', line 8 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?
34 35 36 |
# File 'lib/sane/sane_random.rb', line 34 def in? collection collection.include?(self) end |
#pps(*args) ⇒ Object
a method that outputs several items on one line similar to using pp, this space separates the items passed in and writes them to one line sputs 1,2,3
> 1 2 3
6 7 8 9 10 11 12 13 |
# File 'lib/sane/pps.rb', line 6 def pps *args for arg in args out = arg.to_s print out print " " if out[-1..-1] != " " end puts end |
#present? ⇒ Boolean
14 15 16 |
# File 'lib/sane/present.rb', line 14 def present? true end |
#refute(this_boolean, string = nil) ⇒ Object
14 15 16 |
# File 'lib/sane/test/assertions.rb', line 14 def refute(this_boolean, string = nil) assert(!this_boolean, string) end |
#singleton_class ⇒ Object
53 54 55 |
# File 'lib/sane/sane_random.rb', line 53 def singleton_class class << self; self; end end |
#try2 ⇒ Object
2 3 4 |
# File 'lib/sane/try2.rb', line 2 def try2 self end |