Class: Leftovers::Matchers::NodeHasPositionalArgumentWithValue

Inherits:
Object
  • Object
show all
Includes:
ComparableInstance
Defined in:
lib/leftovers/matchers/node_has_positional_argument_with_value.rb

Instance Method Summary collapse

Methods included from ComparableInstance

#eql?, #hash

Constructor Details

#initialize(position, matcher) ⇒ NodeHasPositionalArgumentWithValue

Returns a new instance of NodeHasPositionalArgumentWithValue.



8
9
10
11
12
13
# File 'lib/leftovers/matchers/node_has_positional_argument_with_value.rb', line 8

def initialize(position, matcher)
  @position = position
  @matcher = matcher

  freeze
end

Instance Method Details

#===(node) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/leftovers/matchers/node_has_positional_argument_with_value.rb', line 15

def ===(node)
  args = node.positional_arguments
  return unless args

  value_node = args[@position]
  @matcher === value_node if value_node
end