Class: SimpleFeed::Key::Template
- Inherits:
-
Object
- Object
- SimpleFeed::Key::Template
- Defined in:
- lib/simplefeed/key/template.rb
Instance Attribute Summary collapse
-
#key_types ⇒ Object
Returns the value of attribute key_types.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#text_template ⇒ Object
Returns the value of attribute text_template.
Instance Method Summary collapse
-
#initialize(namespace, key_types = DEFAULT_TYPES, text_template = DEFAULT_TEXT_TEMPLATE) ⇒ Template
constructor
A new instance of Template.
-
#key_names ⇒ Object
Returns array of key names, such as [:meta, :data].
- #render_options ⇒ Object
Constructor Details
#initialize(namespace, key_types = DEFAULT_TYPES, text_template = DEFAULT_TEXT_TEMPLATE) ⇒ Template
Returns a new instance of Template.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/simplefeed/key/template.rb', line 22 def initialize(namespace, key_types = DEFAULT_TYPES, text_template = DEFAULT_TEXT_TEMPLATE ) self.namespace = namespace self.key_types = key_types self.text_template = text_template self.key_types.each do |type| type.template ||= text_template if text_template end end |
Instance Attribute Details
#key_types ⇒ Object
Returns the value of attribute key_types.
20 21 22 |
# File 'lib/simplefeed/key/template.rb', line 20 def key_types @key_types end |
#namespace ⇒ Object
Returns the value of attribute namespace.
20 21 22 |
# File 'lib/simplefeed/key/template.rb', line 20 def namespace @namespace end |
#text_template ⇒ Object
Returns the value of attribute text_template.
20 21 22 |
# File 'lib/simplefeed/key/template.rb', line 20 def text_template @text_template end |
Instance Method Details
#key_names ⇒ Object
Returns array of key names, such as [:meta, :data]
43 44 45 |
# File 'lib/simplefeed/key/template.rb', line 43 def key_names key_types.map(&:name).map(&:to_s).sort end |
#render_options ⇒ Object
36 37 38 39 40 |
# File 'lib/simplefeed/key/template.rb', line 36 def h = {} h.merge!({ 'namespace' => namespace ? "#{namespace}|" : '' }) h end |