Class: Tumblr::Data::Posts

Inherits:
Array
  • Object
show all
Defined in:
lib/tumblr.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#startObject

Returns the value of attribute start.



63
64
65
# File 'lib/tumblr.rb', line 63

def start
  @start
end

#totalObject

Returns the value of attribute total.



63
64
65
# File 'lib/tumblr.rb', line 63

def total
  @total
end

#typeObject

Returns the value of attribute type.



63
64
65
# File 'lib/tumblr.rb', line 63

def type
  @type
end

Instance Method Details

#to_xmlObject



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