Class: Matcher::MatcherInstance

Inherits:
Object
  • Object
show all
Defined in:
lib/usagi/matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_valueObject

Returns the value of attribute api_value.



15
16
17
# File 'lib/usagi/matcher.rb', line 15

def api_value
  @api_value
end

#argsObject

Returns the value of attribute args.



15
16
17
# File 'lib/usagi/matcher.rb', line 15

def args
  @args
end

Instance Method Details

#error_blockObject



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_messageObject



26
27
28
# File 'lib/usagi/matcher.rb', line 26

def error_message
  error_block.call(api_value)
end

#matches?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/usagi/matcher.rb', line 30

def matches?
  @match.call(api_value)
end