Module: RubyAPI::Mutator::Replacer

Includes:
HashReplacer, PositionReplacer, TokenReplacer, ValueReplacer
Included in:
RubyAPI::Mutator
Defined in:
lib/mutate/replacer.rb

Instance Method Summary collapse

Methods included from ValueReplacer

#replace_value

Methods included from HashReplacer

#hash_arg?, #matching_hash_arg?, #matching_symbol_arg?, #replace_hash_arg, #set_ldelim

Methods included from TokenReplacer

#matching_string_arg?, #replace_arg_token

Methods included from PositionReplacer

#position_arg?, #replace_pos_argument, #replace_position_arg

Instance Method Details

#replace(options) ⇒ Object

:arg => ‘ripper’, :replace_arg => ‘rapper’



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/mutate/replacer.rb', line 100

def replace(options)                       
  if options[:value]
    return replace_value(options) 
  end
  
  if position_arg?(options[:arg])
    return replace_position_arg(options) 
  end
  
  self.arguments.elements.each_with_index do |elem, i|
    case elem
    when Ruby::Arg
      if elem.hash_arg?(options[:arg])
        return elem.replace_hash_arg(options) 
      end
      elem.replace_argument(options)
    end
  end
end

#replace_argument(options) ⇒ Object



120
121
122
123
124
125
# File 'lib/mutate/replacer.rb', line 120

def replace_argument(options)                                    
  case self.arg
  when Ruby::String                                    
    replace_arg_token(options[:replace_arg]) if matching_string_arg?(options[:arg])  
  end
end