Class: GstKitchen::Feed
- Inherits:
-
Object
- Object
- GstKitchen::Feed
- 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
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Feed
constructor
A new instance of Feed.
- #render_as_markdown(text) ⇒ Object
- #to_xml(variables = {}) ⇒ Object
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( = {}) @format = [:format] @template = ERB.new(File.read(File.join(TEMPLATE_PATH, "#{[:template]}.rss.erb"))) end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
52 53 54 |
# File 'lib/gst-kitchen/feed.rb', line 52 def format @format end |
#template ⇒ Object (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 |