Class: Exemplor::Check
- Inherits:
-
Object
- Object
- Exemplor::Check
- Defined in:
- lib/checker.rb
Defined Under Namespace
Classes: Failure
Instance Attribute Summary collapse
-
#expectation ⇒ Object
readonly
Returns the value of attribute expectation.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #[](disambiguate) ⇒ Object
- #failure? ⇒ Boolean
- #info? ⇒ Boolean
-
#initialize(name, value) ⇒ Check
constructor
A new instance of Check.
- #is(expectation) ⇒ Object
- #name ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(name, value) ⇒ Check
Returns a new instance of Check.
6 7 8 9 10 |
# File 'lib/checker.rb', line 6 def initialize(name, value) @name = name @value = value @status = :info end |
Instance Attribute Details
#expectation ⇒ Object (readonly)
Returns the value of attribute expectation.
4 5 6 |
# File 'lib/checker.rb', line 4 def expectation @expectation end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/checker.rb', line 4 def status @status end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'lib/checker.rb', line 4 def value @value end |
Instance Method Details
#[](disambiguate) ⇒ Object
12 13 14 15 |
# File 'lib/checker.rb', line 12 def [](disambiguate) @disambiguate = disambiguate self end |
#failure? ⇒ Boolean
34 35 36 |
# File 'lib/checker.rb', line 34 def failure? status == :failure end |
#info? ⇒ Boolean
38 39 40 |
# File 'lib/checker.rb', line 38 def info? status == :info end |
#is(expectation) ⇒ Object
24 25 26 27 28 |
# File 'lib/checker.rb', line 24 def is(expectation) @expectation = expectation @status = (value == expectation) ? :success : :failure raise Failure if failure? end |
#name ⇒ Object
17 18 19 |
# File 'lib/checker.rb', line 17 def name @name + (defined?(@disambiguate) ? " #{@disambiguate}" : '') end |
#success? ⇒ Boolean
30 31 32 |
# File 'lib/checker.rb', line 30 def success? status == :success end |