Class: Spectre::Assertion::ValueWrapper
- Defined in:
- lib/spectre/assertion.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #evaluate?(predicate, actual, negate) ⇒ Boolean
-
#initialize(val) ⇒ ValueWrapper
constructor
A new instance of ValueWrapper.
-
#to_s ⇒ Object
:nodoc:.
Constructor Details
#initialize(val) ⇒ ValueWrapper
Returns a new instance of ValueWrapper.
10 11 12 |
# File 'lib/spectre/assertion.rb', line 10 def initialize val @val = val end |
Class Method Details
.wrap(val) ⇒ Object
6 7 8 |
# File 'lib/spectre/assertion.rb', line 6 def self.wrap val val.is_a?(ValueWrapper) ? val : ValueWrapper.new(val) end |
Instance Method Details
#evaluate?(predicate, actual, negate) ⇒ Boolean
14 15 16 |
# File 'lib/spectre/assertion.rb', line 14 def evaluate? predicate, actual, negate !(!negate ^ predicate.call(@val, actual)) end |
#to_s ⇒ Object
:nodoc:
19 20 21 22 23 24 |
# File 'lib/spectre/assertion.rb', line 19 def to_s return "\"#{@val}\"" if @val.is_a?(String) return @val.inspect if @val.is_a?(Regexp) @val.to_s end |