Class: Html2rss::AttributePostProcessors::Template
- Inherits:
-
Object
- Object
- Html2rss::AttributePostProcessors::Template
- Defined in:
- lib/html2rss/attribute_post_processors/template.rb
Overview
Returns a formatted String according to the string pattern.
If self
is given as a method, the extracted value will be used.
Imagine this HTML:
<li>
<h1>Product</h1>
<span class="price">23,42€</span>
</li>
YAML usage example:
selectors:
items:
selector: 'li'
price:
selector: '.price'
title:
selector: h1
post_process:
name: template
string: '%s (%s)'
methods:
- self
- price
Would return:
'Product (23,42€)'
Instance Method Summary collapse
-
#get ⇒ String
-
uses String#%.
-
-
#initialize(value, options, item) ⇒ Template
constructor
A new instance of Template.
Constructor Details
#initialize(value, options, item) ⇒ Template
Returns a new instance of Template
34 35 36 37 38 |
# File 'lib/html2rss/attribute_post_processors/template.rb', line 34 def initialize(value, , item) @value = value @options = @item = item end |
Instance Method Details
#get ⇒ String
-
uses String#%
43 44 45 |
# File 'lib/html2rss/attribute_post_processors/template.rb', line 43 def get string % methods end |