Module: Assertion
- Included in:
- Kwatable::Main, Kwatable::Manipulator
- Defined in:
- lib/kwatable/util/assertion.rb
Overview
Defined Under Namespace
Classes: AssertionError, UnreachableError
Class Method Summary collapse
-
.assert(condition, message = '') ⇒ Object
raise AssertionError if condition is false.
-
.assert!(message = '') ⇒ Object
raise AssertionError.
-
.unreachable(message = '') ⇒ Object
raise UnreachableError.
Class Method Details
.assert(condition, message = '') ⇒ Object
raise AssertionError if condition is false
ex.
assert s && !s.empty?, "s=#{s.inspect}"
61 62 63 |
# File 'lib/kwatable/util/assertion.rb', line 61 def assert(condition, ='') _raise_error(AssertionError, , caller()) unless condition end |
.assert!(message = '') ⇒ Object
raise AssertionError
ex.
assert! "s=#{s.inspect}" unless s && !s.empty?
72 73 74 |
# File 'lib/kwatable/util/assertion.rb', line 72 def assert! (='') _raise_error(AssertionError, , caller()) end |
.unreachable(message = '') ⇒ Object
raise UnreachableError
ex.
case value
when true
...
when false
...
else
unreachable
end
90 91 92 |
# File 'lib/kwatable/util/assertion.rb', line 90 def unreachable(='') _raise_error(UnreachableError, , caller()) end |