Class: Checkers::Check
- Inherits:
-
Object
- Object
- Checkers::Check
- Defined in:
- lib/checkers.rb
Instance Attribute Summary collapse
-
#caller ⇒ Object
readonly
Returns the value of attribute caller.
-
#inverted ⇒ Object
readonly
Returns the value of attribute inverted.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#run ⇒ Object
readonly
Returns the value of attribute run.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
- #check(condition, msg = 'Check failed.') ⇒ Object
-
#initialize(subject, caller, run = Checkers.run) ⇒ Check
constructor
A new instance of Check.
Methods included from Checks
#==, #empty, #includes, #matches, #raises
Methods included from Sugar
Constructor Details
#initialize(subject, caller, run = Checkers.run) ⇒ Check
41 42 43 44 45 46 47 |
# File 'lib/checkers.rb', line 41 def initialize(subject, caller, run = Checkers.run) @subject = subject @caller = caller = '' @inverted = false @run = run end |
Instance Attribute Details
#caller ⇒ Object (readonly)
Returns the value of attribute caller.
39 40 41 |
# File 'lib/checkers.rb', line 39 def caller @caller end |
#inverted ⇒ Object (readonly)
Returns the value of attribute inverted.
39 40 41 |
# File 'lib/checkers.rb', line 39 def inverted @inverted end |
#message ⇒ Object
Returns the value of attribute message.
39 40 41 |
# File 'lib/checkers.rb', line 39 def end |
#run ⇒ Object (readonly)
Returns the value of attribute run.
39 40 41 |
# File 'lib/checkers.rb', line 39 def run @run end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
39 40 41 |
# File 'lib/checkers.rb', line 39 def subject @subject end |
Instance Method Details
#check(condition, msg = 'Check failed.') ⇒ Object
49 50 51 52 53 |
# File 'lib/checkers.rb', line 49 def check(condition, msg = 'Check failed.') self. = msg condition = !condition if inverted condition ? run.pass(self) : run.fail(self) end |