Class: ArgumentSpecification::Matchers::BeOneOf
- Inherits:
-
BaseMatcher
- Object
- BaseMatcher
- ArgumentSpecification::Matchers::BeOneOf
- Defined in:
- lib/argspec/matchers/be_one_of.rb
Instance Attribute Summary collapse
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Attributes inherited from BaseMatcher
Instance Method Summary collapse
-
#initialize(*values) ⇒ BeOneOf
constructor
Create a new matcher instance.
-
#matches? ⇒ Boolean
Check if the actual object matches.
Methods inherited from BaseMatcher
#failure_message, #failure_message_when_negated, matcher_name
Constructor Details
#initialize(*values) ⇒ BeOneOf
Create a new matcher instance
Arguments:
values: (Splat|Range)
Example:
>> ArgumentSpecification::Matchers::BeOneOf.new(1, 2)
=> #<ArgumentSpecification::Matchers::BeOneOf:0x00000000000000 @values=[1, 2]>
17 18 19 20 21 22 23 |
# File 'lib/argspec/matchers/be_one_of.rb', line 17 def initialize(*values) if values && values.first.is_a?(Range) @values = values.first.to_a else @values = values end end |
Instance Attribute Details
#values ⇒ Object (readonly)
Returns the value of attribute values.
6 7 8 |
# File 'lib/argspec/matchers/be_one_of.rb', line 6 def values @values end |
Instance Method Details
#matches? ⇒ Boolean
Check if the actual object matches
Example:
>> matcher.matches?
=> true
31 32 33 |
# File 'lib/argspec/matchers/be_one_of.rb', line 31 def matches? @values.include?(@actual) end |