Sha256: ec08c1c8f3814cddfc03bd347c10099a81d549201bcdf30437a2e937e3945a74

Contents?: true

Size: 1.58 KB

Versions: 10

Compression:

Stored size: 1.58 KB

Contents

module FbGraph
  class Photo < Node
    include Connections::Comments
    include Connections::Likes
    include Connections::Likes::Likable
    include Connections::Picture
    include Connections::Tags
    include Connections::Tags::Taggable

    attr_accessor :from, :name, :icon, :source, :height, :width, :images, :link, :created_time, :updated_time, :place

    def initialize(identifier, attributes = {})
      super
      if (from = attributes[:from])
        @from = if from[:category]
          Page.new(from[:id], from)
        else
          User.new(from[:id], from)
        end
      end
      # NOTE:
      # for some reason, facebook uses different parameter names.
      # "name" in GET & "message" in POST
      @name     = attributes[:name] || attributes[:message]
      @icon     = attributes[:icon]
      @source   = attributes[:source]
      @height   = attributes[:height]
      @width    = attributes[:width]
      @link     = attributes[:link]
      @images = []
      if attributes[:images]
        attributes[:images].each do |image|
          @images << Image.new(image)
        end
      end
      if attributes[:created_time]
        @created_time = Time.parse(attributes[:created_time]).utc
      end
      if attributes[:updated_time]
        @updated_time = Time.parse(attributes[:updated_time]).utc
      end
      if attributes[:place]
        @place = Page.new(attributes[:place][:id], :name => attributes[:place][:name], :location => attributes[:place][:location])
      end

      # cached connection
      cache_collections attributes, :comments, :likes, :tags
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fb_graph-2.7.16 lib/fb_graph/photo.rb
fb_graph-2.7.15 lib/fb_graph/photo.rb
fb_graph-2.7.14 lib/fb_graph/photo.rb
fb_graph-2.7.13 lib/fb_graph/photo.rb
fb_graph-2.7.12 lib/fb_graph/photo.rb
fb_graph-2.7.11 lib/fb_graph/photo.rb
fb_graph-2.7.10 lib/fb_graph/photo.rb
fb_graph-2.7.9 lib/fb_graph/photo.rb
fb_graph-2.7.8 lib/fb_graph/photo.rb
fb_graph-2.7.7 lib/fb_graph/photo.rb