Exception: Bang::Assertion

Inherits:
Exception show all
Defined in:
lib/bang.rb

Overview

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ExceptionExtension

#raised?, #rescued?

Class Method Details

.message(s, *a, &b) ⇒ String

TODO:

Imporve this to better handle operators.

Put together an error message representive of the assertion made.

Returns:

  • (String)

    Failed assertion message.



48
49
50
# 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) ⇒ Assertion

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

Returns:



35
36
37
38
39
# 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

Instance Method Details

#assertion?true

Bang::Assertion is alwasy an assertion.

Returns:

  • (true)

    Always true.



57
58
59
# File 'lib/bang.rb', line 57

def assertion?
  true
end