Class: FbGraph::Album

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

Instance Attribute Summary collapse

Attributes inherited from Node

#access_token, #endpoint, #identifier

Instance Method Summary collapse

Methods included from Connections::Picture

#picture

Methods included from Connections::Likes

#likes

Methods included from Connections::Comments

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

Methods included from Connections::Photos

#photo!, #photos

Methods inherited from Node

#connection, #destroy, fetch, #fetch, #update

Methods included from Comparison

#==

Constructor Details

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

Returns a new instance of Album.



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
40
41
42
# File 'lib/fb_graph/album.rb', line 10

def initialize(identifier, attributes = {})
  super
  @from = if (from = attributes[:from])
    if from[:category]
      Page.new(from[:id], from)
    else
      User.new(from[:id], from)
    end
  end
  @name = attributes[:name]
  # NOTE:
  # for some reason, facebook uses different parameter names.
  # "description" in GET & "message" in POST
  @description = attributes[:description] || attributes[:message]
  @location    = attributes[:location]
  @link        = attributes[:link]
  @privacy     = attributes[:privacy]
  @count       = attributes[:count]
  @type        = attributes[:type]

  @cover_photo = if attributes[:cover_photo]
    Photo.new(attributes[:cover_photo])
  end
  @created_time = if attributes[:created_time]
    Time.parse(attributes[:created_time]).utc
  end
  @updated_time = if attributes[:updated_time]
    Time.parse(attributes[:updated_time]).utc
  end

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

Instance Attribute Details

#countObject

Returns the value of attribute count.



8
9
10
# File 'lib/fb_graph/album.rb', line 8

def count
  @count
end

#cover_photoObject

Returns the value of attribute cover_photo.



8
9
10
# File 'lib/fb_graph/album.rb', line 8

def cover_photo
  @cover_photo
end

#created_timeObject

Returns the value of attribute created_time.



8
9
10
# File 'lib/fb_graph/album.rb', line 8

def created_time
  @created_time
end

#descriptionObject

Returns the value of attribute description.



8
9
10
# File 'lib/fb_graph/album.rb', line 8

def description
  @description
end

#fromObject

Returns the value of attribute from.



8
9
10
# File 'lib/fb_graph/album.rb', line 8

def from
  @from
end

Returns the value of attribute link.



8
9
10
# File 'lib/fb_graph/album.rb', line 8

def link
  @link
end

#locationObject

Returns the value of attribute location.



8
9
10
# File 'lib/fb_graph/album.rb', line 8

def location
  @location
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/fb_graph/album.rb', line 8

def name
  @name
end

#privacyObject

Returns the value of attribute privacy.



8
9
10
# File 'lib/fb_graph/album.rb', line 8

def privacy
  @privacy
end

#typeObject

Returns the value of attribute type.



8
9
10
# File 'lib/fb_graph/album.rb', line 8

def type
  @type
end

#updated_timeObject

Returns the value of attribute updated_time.



8
9
10
# File 'lib/fb_graph/album.rb', line 8

def updated_time
  @updated_time
end

Instance Method Details

#picture_with_access_token(size = nil) ⇒ Object

Raises:



44
45
46
47
48
49
# File 'lib/fb_graph/album.rb', line 44

def picture_with_access_token(size = nil)
  raise Unauthorized.new('Album picture connection requires an access token') unless self.access_token
  _endpoint_ = URI.parse picture_without_access_token(size)
  _endpoint_.query = [_endpoint_.query, {:access_token => self.access_token.to_s}.to_query].compact.join('&')
  _endpoint_.to_s
end