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:

  • Product

    23,42€
  • 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, env) ⇒ 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, env)
      @value = value
      @options = env[:options]
      @item = env[:item]
    end

    Instance Method Details

    #get ⇒ String

    Returns:

    • (String)
    
    
    43
    44
    45
    # File 'lib/html2rss/attribute_post_processors/template.rb', line 43
    
    def get
      string % methods
    end