class Realize::Format::StringReplace
This transformer takes in a value and replaces all occurrences of the given original pattern with the replacement pattern.
Attributes
original[R]
replacement[R]
Public Class Methods
new(original:, replacement:)
click to toggle source
# File lib/realize/format/string_replace.rb, line 19 def initialize(original:, replacement:) raise ArgumentError, 'original is required' if original.to_s.empty? @original = original @replacement = replacement.to_s freeze end
Public Instance Methods
transform(_resolver, value, _time, _record)
click to toggle source
# File lib/realize/format/string_replace.rb, line 28 def transform(_resolver, value, _time, _record) value.to_s.gsub(original, replacement) end