class Tumblargh::Resource::Post
Public Class Methods
new(attrs, blog)
click to toggle source
Calls superclass method
Tumblargh::Resource::Base::new
# File lib/tumblargh/resource/post.rb, line 6 def initialize(attrs, blog) @blog = blog super(attrs) end
Public Instance Methods
date()
click to toggle source
# File lib/tumblargh/resource/post.rb, line 24 def date @date ||= @attributes[:date].to_time end
dialogue()
click to toggle source
# File lib/tumblargh/resource/post.rb, line 60 def dialogue @dialogue ||= (@attributes[:dialogue] || []).map { |t| Dialogue.new(t) } end
notes()
click to toggle source
# File lib/tumblargh/resource/post.rb, line 51 def notes @notes || self.notes = API.notes(@blog.domain, :id => id) @notes end
notes=(ary)
click to toggle source
# File lib/tumblargh/resource/post.rb, line 56 def notes=(ary) @notes = ary.map { |n| Note.new(n) } end
photo_url(size=500)
click to toggle source
# File lib/tumblargh/resource/post.rb, line 28 def photo_url(size=500) return nil if (photos.nil? || photos.empty?) photos.first.photo_url size end
photos()
click to toggle source
# File lib/tumblargh/resource/post.rb, line 64 def photos @photos ||= (@attributes[:photos] || []).map { |p| Photo.new(p) } end
title()
click to toggle source
Override method_missing so this does not propagate
# File lib/tumblargh/resource/post.rb, line 20 def title @attributes[:title] end
type()
click to toggle source
# File lib/tumblargh/resource/post.rb, line 11 def type if @attributes[:type] == 'photo' photos.size > 1 ? 'photoset' : 'photo' else @attributes[:type] end end
video(size=500)
click to toggle source
# File lib/tumblargh/resource/post.rb, line 33 def video(size=500) return nil if (player.nil? || player.empty?) size = size.to_i res = player.select do |p| p[:width] == size end res.empty? ? nil : res.first[:embed_code] end