class Bang::Assertion

Bang’s assertion class. Follows standard set by BRASS project, defining ‘#assertion?` method which return `true`.

Public Class Methods

message(s, *a, &b) click to toggle source

Put together an error message representive of the assertion made.

@todo Imporve this to better handle operators.

@return [String] Failed assertion message.

# File lib/bang.rb, line 48
def self.message(s, *a, &b)
  "#{s}(%s)" % a.map{ |e| e.inspect }.join(',')
end
piece(s, a, b, t) click to toggle source

Piece together an Assetion error give the message used to cause the assertion failure.

@return [Assertion] Assertion instance.

# File lib/bang.rb, line 35
def self.piece(s, a, b, t)
  e = new(message(s, *a, &b))
  e.set_backtrace(t)
  e
end

Public Instance Methods

assertion?() click to toggle source

Bang::Assertion is alwasy an assertion.

@return [true] Always true.

# File lib/bang.rb, line 57
def assertion?
  true
end