Method: FbGraph::Album#initialize

Defined in:
lib/fb_graph/album.rb

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

Returns a new instance of Album.



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
43
# File 'lib/fb_graph/album.rb', line 11

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
  cache_collection attributes, :comments
end