Class: Tumblr::Data
- Inherits:
-
Object
- Object
- Tumblr::Data
- Defined in:
- lib/tumblr.rb
Defined Under Namespace
Classes: Conversation, Link, Photo, Post, Posts, Quote, Regular, Tumblelog, Video
Instance Attribute Summary collapse
-
#posts ⇒ Object
Returns the value of attribute posts.
-
#tumblelog ⇒ Object
Returns the value of attribute tumblelog.
Class Method Summary collapse
Instance Method Summary collapse
- #<<(other) ⇒ Object
-
#initialize(doc = nil) ⇒ Data
constructor
A new instance of Data.
- #save(path) ⇒ Object
Constructor Details
Instance Attribute Details
#posts ⇒ Object
Returns the value of attribute posts.
12 13 14 |
# File 'lib/tumblr.rb', line 12 def posts @posts end |
#tumblelog ⇒ Object
Returns the value of attribute tumblelog.
12 13 14 |
# File 'lib/tumblr.rb', line 12 def tumblelog @tumblelog end |
Class Method Details
.load(path) ⇒ Object
21 22 23 |
# File 'lib/tumblr.rb', line 21 def self.load(path) new(REXML::Document.new(File.read(path))) end |
Instance Method Details
#<<(other) ⇒ Object
35 36 37 38 |
# File 'lib/tumblr.rb', line 35 def <<(other) @tumblelog = other.tumblelog unless @tumblelog @posts ? @posts.push(*other.posts) : @posts = other.posts end |
#save(path) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/tumblr.rb', line 25 def save(path) File.open(path, "w") do |file| doc = REXML::Document.new root = doc.add_element "ruby-tumblr", {"version" => "0.1"} root.elements << @tumblelog.to_xml if @tumblelog root.elements << @posts.to_xml if @posts doc.write(file) end end |