Sha256: 389a3a95811f9f3f6f4b4b0ebfeedda16298cfb6385ae6efa6ff2c2e8020e5b1

Contents?: true

Size: 1.17 KB

Versions: 14

Compression:

Stored size: 1.17 KB

Contents

module FbGraph
  class Photo < Node
    include Connections::Comments

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

    def initialize(identifier, options = {})
      super
      if (from = options[:from])
        @from = if from[:category]
          FbGraph::Page.new(from.delete(:id), from)
        else
          FbGraph::User.new(from.delete(:id), from)
        end
      end
      @tags = []
      if options[:tags]
        FbGraph::Collection.new(options[: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    = options[:name] || options[:message]
      @picture = options[:picture]
      @source  = options[:source]
      @height  = options[:height]
      @width   = options[:width]
      @link    = options[:link]
      if options[:created_time]
        @created_time = Time.parse(options[:created_time]).utc
      end
      if options[:updated_time]
        @updated_time = Time.parse(options[:updated_time]).utc
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
fb_graph-0.7.0 lib/fb_graph/photo.rb
fb_graph-0.6.0 lib/fb_graph/photo.rb
fb_graph-0.5.0 lib/fb_graph/photo.rb
fb_graph-0.4.2 lib/fb_graph/photo.rb
fb_graph-0.4.1 lib/fb_graph/photo.rb
fb_graph-0.4.0 lib/fb_graph/photo.rb
fb_graph-0.3.0 lib/fb_graph/photo.rb
fb_graph-0.2.2 lib/fb_graph/photo.rb
fb_graph-0.2.1 lib/fb_graph/photo.rb
fb_graph-0.2.0 lib/fb_graph/photo.rb
fb_graph-0.1.3 lib/fb_graph/photo.rb
fb_graph-0.1.2 lib/fb_graph/photo.rb
fb_graph-0.1.1 lib/fb_graph/photo.rb
fb_graph-0.1.0 lib/fb_graph/photo.rb