lib/rumblr/post.rb in jamescallmebrent-rumblr-0.0.1 vs lib/rumblr/post.rb in jamescallmebrent-rumblr-0.0.2

- old
+ new

@@ -1,11 +1,23 @@ module Rumblr # for attribute details, see Tumblr's documentation: # http://www.tumblr.com/api class Post < Resource + + TYPES = { + 'regular' => "RegularPost", + 'photo' => "PhotoPost", + 'quote' => "QuotePost", + 'link' => "LinkPost", + 'conversation' => "ConversationPost", + 'video' => "VideoPost", + 'audio' => "AudioPost" + } + attr_reader :id, :url, :type, :unix_timestamp, :date_gmt, :date, :tags, :private + attr_accessor :tumblelog def initialize(attrs={}) @private = false super end @@ -16,36 +28,75 @@ def public? !self.private? end + def attribute_hash + {:date => date} + end + end class RegularPost < Post - attr_reader :title, :body + attr_accessor :title, :body + + def attribute_hash + super.merge(:title => title, :body => body) + end + end class PhotoPost < Post - attr_reader :source, :data, :caption, :click_through_url + attr_accessor :source, :data, :caption, :click_through_url + + def attribute_hash + super.merge(:source => source, :data => data, :caption => caption, :click_through_url => click_through_url) + end + end class QuotePost < Post - attr_reader :quote, :source + attr_accessor :quote, :source + + def attribute_hash + super.merge(:quote => quote, :source => source) + end + end class LinkPost < Post - attr_reader :name, :url, :description + attr_accessor :name, :url, :description + + def attribute_hash + super.merge(:name => name, :url => url, :description => description) + end + end class ConversationPost < Post - attr_reader :title, :conversation + attr_accessor :title, :conversation + + def attribute_hash + super.merge(:title => title, :conversation => conversation) + end + end class VideoPost < Post - attr_reader :embed, :data, :title, :caption + attr_accessor :embed, :data, :title, :caption + + def attribute_hash + super.merge(:embed => embed, :data => data, :title => title, :caption => caption) + end + end class AudioPost < Post - attr_reader :data, :caption + attr_accessor :data, :caption + + def attribute_hash + super.merge(:data => data, :caption => caption) + end + end -end \ No newline at end of file +end