Class: FbGraph::Photo

Inherits:
Node
  • Object
show all
Includes:
Connections::Comments, Connections::Likes
Defined in:
lib/fb_graph/photo.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#access_token, #endpoint, #identifier

Instance Method Summary collapse

Methods included from Connections::Likes

#likes

Methods included from Connections::Comments

#comment!, #comments, #like!, #unlike!

Methods inherited from Node

#connection, #destroy, fetch, #fetch

Methods included from Comparison

#==

Constructor Details

#initialize(identifier, attributes = {}) ⇒ Photo

Returns a new instance of Photo.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fb_graph/photo.rb', line 8

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

Instance Attribute Details

#created_timeObject

Returns the value of attribute created_time.



6
7
8
# File 'lib/fb_graph/photo.rb', line 6

def created_time
  @created_time
end

#fromObject

Returns the value of attribute from.



6
7
8
# File 'lib/fb_graph/photo.rb', line 6

def from
  @from
end

#heightObject

Returns the value of attribute height.



6
7
8
# File 'lib/fb_graph/photo.rb', line 6

def height
  @height
end

#iconObject

Returns the value of attribute icon.



6
7
8
# File 'lib/fb_graph/photo.rb', line 6

def icon
  @icon
end

Returns the value of attribute link.



6
7
8
# File 'lib/fb_graph/photo.rb', line 6

def link
  @link
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/fb_graph/photo.rb', line 6

def name
  @name
end

#pictureObject

Returns the value of attribute picture.



6
7
8
# File 'lib/fb_graph/photo.rb', line 6

def picture
  @picture
end

#sourceObject

Returns the value of attribute source.



6
7
8
# File 'lib/fb_graph/photo.rb', line 6

def source
  @source
end

#tagsObject

Returns the value of attribute tags.



6
7
8
# File 'lib/fb_graph/photo.rb', line 6

def tags
  @tags
end

#updated_timeObject

Returns the value of attribute updated_time.



6
7
8
# File 'lib/fb_graph/photo.rb', line 6

def updated_time
  @updated_time
end

#widthObject

Returns the value of attribute width.



6
7
8
# File 'lib/fb_graph/photo.rb', line 6

def width
  @width
end