Module: Rafini
- Defined in:
- lib/rafini.rb,
lib/rafini/hash.rb,
lib/rafini/array.rb,
lib/rafini/empty.rb,
lib/rafini/object.rb,
lib/rafini/string.rb,
lib/rafini/integer.rb,
lib/rafini/requires.rb,
lib/rafini/exception.rb,
lib/rafini/odometers.rb
Defined Under Namespace
Modules: Array, Empty, Exception, Hash, Integer, Object, Odometers, Requires, String
Constant Summary collapse
- VERSION =
'3.3.230213'
Class Method Summary collapse
-
.bang!(msg = nil, bang = Exception, &block) ⇒ Object
Module version of puts bang! Returns either the value or error of the block.
- .requires(*list) ⇒ Object
-
.thread_bang!(header = nil, bang = Exception) ⇒ Object
The Thread wrapped version of bang! I often do Thread.new do begin …
Class Method Details
.bang!(msg = nil, bang = Exception, &block) ⇒ Object
Module version of puts bang! Returns either the value or error of the block.
value = Rafini.bang!('Ooops! Not perfect?') do
# Perfect code here...
end
32 33 34 35 36 37 38 39 40 |
# File 'lib/rafini/exception.rb', line 32 def Rafini.bang!(msg=nil, bang=Exception, &block) e = nil begin e = block.call rescue bang => e e.puts(msg) end e end |
.requires(*list) ⇒ Object
44 |
# File 'lib/rafini/requires.rb', line 44 def self.requires(*list) = Kernel.requires(*list) |
.thread_bang!(header = nil, bang = Exception) ⇒ Object
The Thread wrapped version of bang! I often do
Thread.new do
begin
... stuff ..
rescue Exception
puts 'blah blah...'
puts $!.message if $VERBOSE
puts $!.backtrace if $DEBUG
end
end
With the following below, I’ll be able to say Rafini.thread_bang!(‘blah blah…’){ …stuff… }
55 56 57 |
# File 'lib/rafini/exception.rb', line 55 def Rafini.thread_bang!(header=nil, bang=Exception, &) Thread.new{Rafini.bang!(header, bang, &)} end |