Class: Atomizer::FeedItem
- Inherits:
-
Object
- Object
- Atomizer::FeedItem
show all
- Includes:
- Buildable
- Defined in:
- lib/atomizer/feed_item.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Buildable
#to_atom
Constructor Details
#initialize(options = {}) ⇒ FeedItem
Returns a new instance of FeedItem.
32
33
34
35
36
37
38
39
|
# File 'lib/atomizer/feed_item.rb', line 32
def initialize(options={})
self.class.feed_attributes.each do |a|
if v = (options[a.to_sym] || options[a.to_s])
meth = "#{a}="
send(meth, v) if respond_to?(meth) && v && v != ""
end
end
end
|
Class Method Details
.feed_attributes(*attrs) ⇒ Object
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/atomizer/feed_item.rb', line 12
def feed_attributes(*attrs)
@attributes ||= []
if attrs && attrs.size > 0
@attributes.push(*attrs)
attrs.each do |a|
attr_accessor a
end
end
@attributes
end
|
.feed_no_collection_group_tag ⇒ Object
27
28
29
|
# File 'lib/atomizer/feed_item.rb', line 27
def feed_no_collection_group_tag
@feed_no_collection_group_tag || false
end
|
.feed_no_collection_group_tag! ⇒ Object
23
24
25
|
# File 'lib/atomizer/feed_item.rb', line 23
def feed_no_collection_group_tag!
@feed_no_collection_group_tag = true
end
|
.feed_tag_name(tag_name = nil) ⇒ Object
7
8
9
10
|
# File 'lib/atomizer/feed_item.rb', line 7
def feed_tag_name(tag_name=nil)
@feed_tag_name = tag_name.to_s if tag_name
@feed_tag_name
end
|
Instance Method Details
#to_xml(xml, root_element = true) ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'lib/atomizer/feed_item.rb', line 41
def to_xml(xml, root_element=true)
if root_element
xml.send(self.class.feed_tag_name) do |child_xml|
feed_attributes_to_xml(child_xml)
end
else
feed_attributes_to_xml(xml)
end
end
|