Class: GstKitchen::Feed

Inherits:
Object
  • Object
show all
Defined in:
lib/gst-kitchen/feed.rb

Defined Under Namespace

Classes: ShownotesRenderer

Constant Summary collapse

TEMPLATE_PATH =
File.join(File.dirname(__FILE__), "..", "..", "templates")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Feed

Returns a new instance of Feed.



54
55
56
57
# File 'lib/gst-kitchen/feed.rb', line 54

def initialize(options = {})
  @format   = options[:format]
  @template = ERB.new(File.read(File.join(TEMPLATE_PATH, "#{options[:template]}.rss.erb")))
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



52
53
54
# File 'lib/gst-kitchen/feed.rb', line 52

def format
  @format
end

#templateObject (readonly)

Returns the value of attribute template.



52
53
54
# File 'lib/gst-kitchen/feed.rb', line 52

def template
  @template
end

Instance Method Details

#render_as_markdown(text) ⇒ Object



59
60
61
62
# File 'lib/gst-kitchen/feed.rb', line 59

def render_as_markdown(text)
  markdown = Redcarpet::Markdown.new(ShownotesRenderer, autolink: true)
  markdown.render text
end

#to_xml(variables = {}) ⇒ Object



64
65
66
67
68
# File 'lib/gst-kitchen/feed.rb', line 64

def to_xml(variables = {})
  variables.each { |var, value| instance_variable_set("@#{var}", value) }

  @template.result(binding)
end