Class: Tumblr::Data::Conversation

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

Instance Attribute Summary collapse

Attributes inherited from Post

#bookmarklet, #date, #postid, #url

Instance Method Summary collapse

Constructor Details

#initialize(elt, tz) ⇒ Conversation

Returns a new instance of Conversation.



217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/tumblr.rb', line 217

def initialize(elt, tz)
  super
  if elt.elements["conversation-title"]
    @title = elt.elements["conversation-title"]
  end
  @text = elt.elements["conversation-text"].text
  @lines = []
  elt.elements.each("conversation-line") do |line|
    name = line.attributes["name"]
    label = line.attributes["label"]
    @lines << [name, label, line.text]
  end
end

Instance Attribute Details

#linesObject

Returns the value of attribute lines.



215
216
217
# File 'lib/tumblr.rb', line 215

def lines
  @lines
end

#titleObject

Returns the value of attribute title.



215
216
217
# File 'lib/tumblr.rb', line 215

def title
  @title
end

Instance Method Details

#to_xmlObject



231
232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/tumblr.rb', line 231

def to_xml
  elt = super
  elt.attributes["type"] = "conversation"
  if @title
    (elt.add_element "conversation-title").text = @title
  end
  text = elt.add_element "conversation-text"
  text.text = @text
  @lines.each do |line|
    e = elt.add_element "conversation-line", {"name" => line[0], "label" => line[1]}
    e.text = line[2]
  end
  return elt
end