Class: Rulix::Mutators::Replace

Inherits:
Object
  • Object
show all
Defined in:
lib/rulix/mutators/replace.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Replace

Returns a new instance of Replace.



6
7
8
# File 'lib/rulix/mutators/replace.rb', line 6

def initialize args
  self.args = args
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



4
5
6
# File 'lib/rulix/mutators/replace.rb', line 4

def args
  @args
end

Instance Method Details

#call(string) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
# File 'lib/rulix/mutators/replace.rb', line 14

def call string
  raise ArgumentError, "argument is not a string" unless string.is_a? String
  
  string.gsub *args
end

#to_procObject



10
11
12
# File 'lib/rulix/mutators/replace.rb', line 10

def to_proc
  method(:call)
end