Sha256: e0cc712893844e79e16c458a88cabc089bfa6ab1c51b9293650d6ae43cd5e6ba
Contents?: true
Size: 968 Bytes
Versions: 2
Compression:
Stored size: 968 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 options = env[:options] @pattern = options[:pattern].to_regexp || options[:pattern] @replacement = 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.9.0 | lib/html2rss/attribute_post_processors/gsub.rb |
html2rss-0.8.2 | lib/html2rss/attribute_post_processors/gsub.rb |