Class: Tumblr::Data::Posts
- Inherits:
-
Array
- Object
- Array
- Tumblr::Data::Posts
- Defined in:
- lib/tumblr.rb
Instance Attribute Summary collapse
-
#start ⇒ Object
Returns the value of attribute start.
-
#total ⇒ Object
Returns the value of attribute total.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(elt, tz) ⇒ Posts
constructor
A new instance of Posts.
- #to_xml ⇒ Object
Constructor Details
#initialize(elt, tz) ⇒ Posts
Returns a new instance of Posts.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/tumblr.rb', line 65 def initialize(elt, tz) @total = elt.attributes["total"].to_i @start = elt.attributes["start"].to_i if elt.attributes.has_key? "start" @type = elt.attributes["type"] elt.elements.each("post") do |e| push((case e.attributes["type"] when "regular"; Regular when "quote"; Quote when "photo"; Photo when "link"; Link when "video"; Video when "conversation"; Conversation end).new(e, tz)) end end |
Instance Attribute Details
#start ⇒ Object
Returns the value of attribute start.
63 64 65 |
# File 'lib/tumblr.rb', line 63 def start @start end |
#total ⇒ Object
Returns the value of attribute total.
63 64 65 |
# File 'lib/tumblr.rb', line 63 def total @total end |
#type ⇒ Object
Returns the value of attribute type.
63 64 65 |
# File 'lib/tumblr.rb', line 63 def type @type end |
Instance Method Details
#to_xml ⇒ Object
82 83 84 85 86 87 88 89 90 |
# File 'lib/tumblr.rb', line 82 def to_xml elt = REXML::Element.new("posts") elt.attributes["total"] = @total elt.attributes["type"] = @type each do |post| elt.elements << post.to_xml end return elt end |