Class: Tumblr::Data::Link

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

Instance Attribute Summary collapse

Attributes inherited from Post

#bookmarklet, #date, #postid

Instance Method Summary collapse

Constructor Details

#initialize(elt, tz) ⇒ Link

Returns a new instance of Link.



194
195
196
197
198
199
# File 'lib/tumblr.rb', line 194

def initialize(elt, tz)
  super
  @text = elt.elements["link-text"].text if elt.elements["link-text"]
  @url = elt.elements["link-url"].text
  @description = elt.elements["link-description"].text if elt.elements["link-description"]
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



192
193
194
# File 'lib/tumblr.rb', line 192

def description
  @description
end

#nameObject

Returns the value of attribute name.



192
193
194
# File 'lib/tumblr.rb', line 192

def name
  @name
end

#urlObject

Returns the value of attribute url.



192
193
194
# File 'lib/tumblr.rb', line 192

def url
  @url
end

Instance Method Details

#to_xmlObject



201
202
203
204
205
206
207
208
209
210
211
# File 'lib/tumblr.rb', line 201

def to_xml
  elt = super
  elt.attributes["type"] = "link"
  name = elt.add_element "link-text"
  name.text = @text
  url = elt.add_element "link-url"
  url.text = @url
  description = elt.add_element "link-description"
  description.text = @description
  return elt
end