module Rafini

Constants

VERSION

Public Class Methods

bang!(msg=nil, bang=Exception, &block) click to toggle source

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
# 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) click to toggle source
# File lib/rafini/requires.rb, line 44
  def self.requires(*list) = Kernel.requires(*list)
end
thread_bang!(header=nil, bang=Exception, &) click to toggle source

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… }

# File lib/rafini/exception.rb, line 55
def Rafini.thread_bang!(header=nil, bang=Exception, &)
  Thread.new{Rafini.bang!(header, bang, &)}
end