Sha256: 8ed7154702e4b162fa09673813915ed5a5186950440f3b7a6e5ce6ce62e56973
Contents?: true
Size: 942 Bytes
Versions: 1
Compression:
Stored size: 942 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
html2rss-0.7.0 | lib/html2rss/attribute_post_processors/gsub.rb |