Class: Matcher::MatcherInstance
- Inherits:
-
Object
- Object
- Matcher::MatcherInstance
- Defined in:
- lib/usagi/matcher.rb
Instance Attribute Summary collapse
-
#api_value ⇒ Object
Returns the value of attribute api_value.
-
#args ⇒ Object
Returns the value of attribute args.
Instance Method Summary collapse
- #error_block ⇒ Object
- #error_message ⇒ Object
-
#initialize(matcher_block, api_value, args) ⇒ MatcherInstance
constructor
A new instance of MatcherInstance.
- #matches? ⇒ Boolean
Constructor Details
#initialize(matcher_block, api_value, args) ⇒ MatcherInstance
Returns a new instance of MatcherInstance.
17 18 19 20 |
# File 'lib/usagi/matcher.rb', line 17 def initialize(matcher_block, api_value, args) @api_value = api_value instance_exec(*args, &matcher_block) end |
Instance Attribute Details
#api_value ⇒ Object
Returns the value of attribute api_value.
15 16 17 |
# File 'lib/usagi/matcher.rb', line 15 def api_value @api_value end |
#args ⇒ Object
Returns the value of attribute args.
15 16 17 |
# File 'lib/usagi/matcher.rb', line 15 def args @args end |
Instance Method Details
#error_block ⇒ Object
22 23 24 |
# File 'lib/usagi/matcher.rb', line 22 def error_block @error || lambda{|api_value| "non-matching value (got: #{api_value})" } end |
#error_message ⇒ Object
26 27 28 |
# File 'lib/usagi/matcher.rb', line 26 def error_block.call(api_value) end |
#matches? ⇒ Boolean
30 31 32 |
# File 'lib/usagi/matcher.rb', line 30 def matches? @match.call(api_value) end |