Class: Html2rss::AttributePostProcessors::Template

Inherits:
Object
  • Object
show all
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

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, options, item)
  @value = value
  @options = options
  @item = item
end

Instance Method Details

#getString

Returns:

  • (String)


43
44
45
# File 'lib/html2rss/attribute_post_processors/template.rb', line 43

def get
  string % methods
end