Class: Tumblr::Data::Photo
Instance Attribute Summary collapse
-
#caption ⇒ Object
Returns the value of attribute caption.
-
#urls ⇒ Object
Returns the value of attribute urls.
Attributes inherited from Post
#bookmarklet, #date, #postid, #url
Instance Method Summary collapse
-
#initialize(elt, tz) ⇒ Photo
constructor
A new instance of Photo.
- #to_xml ⇒ Object
Constructor Details
#initialize(elt, tz) ⇒ Photo
Returns a new instance of Photo.
166 167 168 169 170 171 172 173 174 175 |
# File 'lib/tumblr.rb', line 166 def initialize(elt, tz) super if elt.elements["photo-caption"] @caption = elt.elements["photo-caption"].text end @urls = Hash.new elt.elements.each("photo-url") do |url| @urls[url.attributes["max-width"].to_i] = url.text end end |
Instance Attribute Details
#caption ⇒ Object
Returns the value of attribute caption.
164 165 166 |
# File 'lib/tumblr.rb', line 164 def @caption end |
#urls ⇒ Object
Returns the value of attribute urls.
164 165 166 |
# File 'lib/tumblr.rb', line 164 def urls @urls end |
Instance Method Details
#to_xml ⇒ Object
177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/tumblr.rb', line 177 def to_xml elt = super elt.attributes["type"] = "photo" if @caption (elt.add_element "photo-caption").text = @caption end @urls.each do |width, url| e = elt.add_element "photo-url", {"max-width" => width} e.text = url end return elt end |