Class: AE::Check::Proc
Overview
The Check::Proc class encapsulates a labeled procedure for making assertions using the ‘ok`/`no` methods.
Instance Method Summary collapse
-
#call(*args) ⇒ Object
Call check procedure.
-
#initialize(options = {}, &check) ⇒ Proc
constructor
Setup new check procedure.
- #message(&block) ⇒ Object
- #message=(msg) ⇒ Object
- #no!(*args) ⇒ Object
- #ok!(*args) ⇒ Object
- #to_s(*args) ⇒ Object
Constructor Details
#initialize(options = {}, &check) ⇒ Proc
Setup new check procedure.
14 15 16 17 18 |
# File 'lib/ae/check.rb', line 14 def initialize(={}, &check) @name = [:name] @message = [:message] || @name @check = check end |
Instance Method Details
#call(*args) ⇒ Object
Call check procedure.
34 35 36 |
# File 'lib/ae/check.rb', line 34 def call(*args) @check.call(*args) end |
#message(&block) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/ae/check.rb', line 21 def (&block) if block @message = end @message end |
#message=(msg) ⇒ Object
29 30 31 |
# File 'lib/ae/check.rb', line 29 def (msg) @message = msg end |
#no!(*args) ⇒ Object
57 58 59 |
# File 'lib/ae/check.rb', line 57 def no!(*args) refute(call(*args), to_s(*args)) end |
#ok!(*args) ⇒ Object
52 53 54 |
# File 'lib/ae/check.rb', line 52 def ok!(*args) assert(call(*args), to_s(*args)) end |