Class: ActiveMutator::Operators::ConditionalBoundary

Inherits:
Base
  • Object
show all
Defined in:
lib/active_mutator/operators/conditional_boundary.rb

Constant Summary collapse

MAP =
{ :> => ">=", :>= => ">", :< => "<=", :<= => "<" }.freeze

Constants inherited from Base

Base::REGISTRY

Instance Method Summary collapse

Methods inherited from Base

all, inherited

Instance Method Details

#edits(node) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/active_mutator/operators/conditional_boundary.rb', line 6

def edits(node)
  return [] unless node.is_a?(Prism::CallNode) && MAP.key?(node.name)
  return [] unless node.receiver && node.arguments&.arguments&.size == 1

  replacement = MAP.fetch(node.name)
  [edit(loc_range(node.message_loc), replacement,
        "replace `#{node.name}` with `#{replacement}`")]
end