Class: Avm::Files::TextReplacer
- Inherits:
-
Object
- Object
- Avm::Files::TextReplacer
- Defined in:
- lib/avm/files/text_replacer.rb,
lib/avm/files/text_replacer/gsub.rb
Defined Under Namespace
Classes: Gsub
Instance Method Summary collapse
- #apply(input) ⇒ Object
-
#file_apply(file) ⇒ Object
rubocop:disable Naming/PredicateMethod.
- #gsub(from, to) ⇒ Object
Instance Method Details
#apply(input) ⇒ Object
10 11 12 |
# File 'lib/avm/files/text_replacer.rb', line 10 def apply(input) replacements.inject(input) { |a, e| e.apply(a) } end |
#file_apply(file) ⇒ Object
rubocop:disable Naming/PredicateMethod
14 15 16 17 18 19 20 21 22 |
# File 'lib/avm/files/text_replacer.rb', line 14 def file_apply(file) # rubocop:disable Naming/PredicateMethod 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
24 25 26 |
# File 'lib/avm/files/text_replacer.rb', line 24 def gsub(from, to) replacement(::Avm::Files::TextReplacer::Gsub.new(from, to)) end |