Class: Ramcrest::Comparable::Matcher
- Inherits:
-
Object
- Object
- Ramcrest::Comparable::Matcher
- Includes:
- Matcher
- Defined in:
- lib/ramcrest/comparable.rb
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(name, operator, expected) ⇒ Matcher
constructor
A new instance of Matcher.
- #matches?(actual) ⇒ Boolean
Methods included from Matcher
#do_match, #mismatch, #success
Constructor Details
#initialize(name, operator, expected) ⇒ Matcher
Returns a new instance of Matcher.
26 27 28 29 30 |
# File 'lib/ramcrest/comparable.rb', line 26 def initialize(name, operator, expected) @name = name @operator = operator @expected = expected end |
Instance Method Details
#description ⇒ Object
40 41 42 |
# File 'lib/ramcrest/comparable.rb', line 40 def description "#{@name} <#{@expected}>" end |
#matches?(actual) ⇒ Boolean
32 33 34 35 36 37 38 |
# File 'lib/ramcrest/comparable.rb', line 32 def matches?(actual) if actual.send(@operator, @expected) success else mismatch("was <#{actual}>") end end |