Class: SimpleFeed::Key::TextTemplate

Inherits:
Struct
  • Object
show all
Defined in:
lib/simplefeed/key/template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#textObject

Returns the value of attribute text

Returns:

  • (Object)

    the current value of text


7
8
9
# File 'lib/simplefeed/key/template.rb', line 7

def text
  @text
end

Instance Method Details

#render(params = {}) ⇒ Object


8
9
10
11
12
13
14
# File 'lib/simplefeed/key/template.rb', line 8

def render(params = {})
  output = self.text.dup
  params.each_pair do |key, value|
    output.gsub!(%r[{{\s*#{key}\s*}}], value.to_s)
  end
  output
end