Sha256: 6e6f50d099f3a0955eede966a99c67e0395623a82848601c18fc18f54505c68b

Contents?: true

Size: 1.29 KB

Versions: 17

Compression:

Stored size: 1.29 KB

Contents

module FbGraph
  class Photo < Node
    include Connections::Comments
    include Connections::Likes

    attr_accessor :from, :tags, :name, :picture, :icon, :source, :height, :width, :link, :created_time, :updated_time

    def initialize(identifier, attributes = {})
      super
      if (from = attributes[:from])
        @from = if from[:category]
          FbGraph::Page.new(from.delete(:id), from)
        else
          FbGraph::User.new(from.delete(:id), from)
        end
      end
      @tags = []
      if attributes[:tags]
        FbGraph::Collection.new(attributes[:tags]).each do |tag|
          @tags << FbGraph::Tag.new(tag.delete(:id), tag)
        end
      end
      # NOTE:
      # for some reason, facebook uses different parameter names.
      # "name" in GET & "message" in POST
      @name    = attributes[:name] || attributes[:message]
      @picture = attributes[:picture]
      @icon    = attributes[:icon]
      @source  = attributes[:source]
      @height  = attributes[:height]
      @width   = attributes[:width]
      @link    = attributes[:link]
      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
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
fb_graph-1.1.4 lib/fb_graph/photo.rb
fb_graph-1.1.3 lib/fb_graph/photo.rb
fb_graph-1.1.2 lib/fb_graph/photo.rb
fb_graph-1.1.1 lib/fb_graph/photo.rb
fb_graph-1.1.0 lib/fb_graph/photo.rb
fb_graph-1.0.7 lib/fb_graph/photo.rb
fb_graph-1.0.6 lib/fb_graph/photo.rb
fb_graph-1.0.5 lib/fb_graph/photo.rb
palidanx-fb_graph-1.0.4 lib/fb_graph/photo.rb
fb_graph-1.0.4 lib/fb_graph/photo.rb
fb_graph-1.0.3 lib/fb_graph/photo.rb
fb_graph-1.0.2 lib/fb_graph/photo.rb
fb_graph-1.0.1 lib/fb_graph/photo.rb
fb_graph-1.0.0 lib/fb_graph/photo.rb
fb_graph-0.8.0 lib/fb_graph/photo.rb
fb_graph-0.7.3 lib/fb_graph/photo.rb
fb_graph-0.7.2 lib/fb_graph/photo.rb