Sha256: 1ad93f67c07e9e0c93ef9870bc507795119898ee649e651eff8b6e8f2012c589
Contents?: true
Size: 957 Bytes
Versions: 2
Compression:
Stored size: 957 Bytes
Contents
require 'to_regexp' module Html2rss module AttributePostProcessors ## # # Imagine this HTML: # <h1>Foo bar and boo<h1> # # YAML usage example: # selectors: # title: # selector: h1 # post_process: # name: gsub # pattern: boo # replacement: baz # # Would return: # 'Foo bar and baz' # # `pattern` can be a Regexp or a String. # # `replacement` can be a String or a Hash. # # See the doc on [String#gsub](https://ruby-doc.org/core/String.html#method-i-gsub) for more info. class Gsub def initialize(value, env) @value = value @pattern = env[:options]['pattern'].to_regexp || env[:options]['pattern'] @replacement = env[:options]['replacement'] end ## # @return [String] def get @value.to_s.gsub(@pattern, @replacement) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
html2rss-0.8.1 | lib/html2rss/attribute_post_processors/gsub.rb |
html2rss-0.8.0 | lib/html2rss/attribute_post_processors/gsub.rb |