Class: Avm::Files::TextReplacer

Inherits:
Object
  • Object
show all
Defined in:
lib/avm/files/text_replacer.rb,
lib/avm/files/text_replacer/gsub.rb

Defined Under Namespace

Classes: Gsub

Instance Method Summary collapse

Instance Method Details

#apply(input) ⇒ Object



13
14
15
# File 'lib/avm/files/text_replacer.rb', line 13

def apply(input)
  replacements.inject(input) { |a, e| e.apply(a) }
end

#file_apply(file) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/avm/files/text_replacer.rb', line 17

def file_apply(file)
  file = file.to_pathname
  input = file.read
  output = apply(file.read)
  return false if output == input

  file.write(output)
  true
end

#gsub(from, to) ⇒ Object



27
28
29
# File 'lib/avm/files/text_replacer.rb', line 27

def gsub(from, to)
  replacement(::Avm::Files::TextReplacer::Gsub.new(from, to))
end