Class: Tumblr::Data::Post

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

Direct Known Subclasses

Conversation, Link, Photo, Quote, Regular, Video

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(elt, tz) ⇒ Post

Returns a new instance of Post.



96
97
98
99
100
101
102
# File 'lib/tumblr.rb', line 96

def initialize(elt, tz)
  @postid = elt.attributes["id"]
  @url = elt.attributes["url"]
  @date = Time.parse(elt.attributes["date"] + tz.strftime("%Z"))
  @bookmarklet = (elt.attributes["bookmarklet"] == "true")
  @timezone = tz
end

Instance Attribute Details

#bookmarkletObject (readonly)

Returns the value of attribute bookmarklet.



94
95
96
# File 'lib/tumblr.rb', line 94

def bookmarklet
  @bookmarklet
end

#dateObject (readonly)

Returns the value of attribute date.



94
95
96
# File 'lib/tumblr.rb', line 94

def date
  @date
end

#postidObject (readonly)

Returns the value of attribute postid.



94
95
96
# File 'lib/tumblr.rb', line 94

def postid
  @postid
end

#urlObject (readonly)

Returns the value of attribute url.



94
95
96
# File 'lib/tumblr.rb', line 94

def url
  @url
end

Instance Method Details

#to_xmlObject



104
105
106
107
108
109
110
111
# File 'lib/tumblr.rb', line 104

def to_xml
  elt = REXML::Element.new("post")
  elt.attributes["id"] = @postid
  elt.attributes["date"] = @date.strftime("%a, %d %b %Y %X")
  elt.attributes["bookmarklet"] = "true" if @bookmarklet
  elt.attributes["url"] = @url
  return elt
end