Class: Awestruct::Extensions::Gsub
- Inherits:
-
Object
- Object
- Awestruct::Extensions::Gsub
- Defined in:
- lib/awestruct/extensions/gsub.rb
Instance Method Summary collapse
-
#initialize(pattern, replacement, options = {}) ⇒ Gsub
constructor
A new instance of Gsub.
- #transform(site, page, rendered) ⇒ Object
Constructor Details
#initialize(pattern, replacement, options = {}) ⇒ Gsub
Returns a new instance of Gsub.
5 6 7 8 9 |
# File 'lib/awestruct/extensions/gsub.rb', line 5 def initialize(pattern, replacement, = {}) @pattern = pattern @replacement = replacement @gsub_required = [:gsub_required] || lambda { |site, page| page.output_path.end_with?(".html") } end |
Instance Method Details
#transform(site, page, rendered) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/awestruct/extensions/gsub.rb', line 11 def transform(site, page, rendered) if (@gsub_required.call(site, page)) rendered = rendered.gsub(@pattern, @replacement) end rendered end |