Sha256: 7d3a7e7093957906c2c64c6ff38d1451c7fe37cd0e482c59f7fd6ebdcdded67b

Contents?: true

Size: 1.46 KB

Versions: 31

Compression:

Stored size: 1.46 KB

Contents

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

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

    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]
      @position = attributes[:position]
      @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

      # cached connection
      @_tags_ = Collection.new(attributes[:tags])
      @_comments_ = Collection.new(attributes[:comments])
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
fb_graph-2.2.0.alpha2 lib/fb_graph/photo.rb
fb_graph-2.2.0.alpha lib/fb_graph/photo.rb
fb_graph-2.1.13 lib/fb_graph/photo.rb
fb_graph-2.1.12 lib/fb_graph/photo.rb
fb_graph-2.1.11 lib/fb_graph/photo.rb
fb_graph-2.1.10 lib/fb_graph/photo.rb
fb_graph-2.1.9 lib/fb_graph/photo.rb
fb_graph-2.1.8 lib/fb_graph/photo.rb
fb_graph-2.1.7 lib/fb_graph/photo.rb
fb_graph-2.1.6 lib/fb_graph/photo.rb
fb_graph-2.1.5 lib/fb_graph/photo.rb
fb_graph-2.1.4 lib/fb_graph/photo.rb
fb_graph-2.1.3 lib/fb_graph/photo.rb
fb_graph-2.1.2 lib/fb_graph/photo.rb
fb_graph-2.1.1 lib/fb_graph/photo.rb
fb_graph-2.1.0 lib/fb_graph/photo.rb
fb_graph-2.1.0.alpha lib/fb_graph/photo.rb
fb_graph-2.0.2 lib/fb_graph/photo.rb
fb_graph-2.0.1 lib/fb_graph/photo.rb
fb_graph-2.0.0 lib/fb_graph/photo.rb