Class: FbGraph::Achievement

Inherits:
Node
  • Object
show all
Defined in:
lib/fb_graph/achievement.rb

Instance Attribute Summary (collapse)

Attributes inherited from Node

#access_token, #endpoint, #identifier, #raw_attributes

Instance Method Summary (collapse)

Methods inherited from Node

#connection, #fetch, fetch, #update

Methods included from Comparison

#==

Constructor Details

- (Achievement) initialize(identifier, attributes = {})



5
6
7
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
# File 'lib/fb_graph/achievement.rb', line 5

def initialize(identifier, attributes = {})
  super

  # TODO: Handle data, context in smarter way.
  [:type, :title, :url, :description, :data, :context].each do |key|
    send "#{key}=", attributes[key]
  end

  if self.data
    @points = self.data[:points]
  end

  if self.context
    @display_order = self.context[:display_order]
  end

  @images = []
  if _images_ = attributes[:image]
    _images_.each do |_image_|
      @images << _image_[:url]
    end
  end
  @image = @images.first

  if application = attributes[:application]
    application[:link] = application[:url] # for some reason, FB uses "url" only here..
    @application = Application.new(application[:id], application)
  end

  if attributes[:updated_time]
    @updated_time = Time.parse(attributes[:updated_time]).utc
  end
end

Instance Attribute Details

- (Object) application

Returns the value of attribute application



3
4
5
# File 'lib/fb_graph/achievement.rb', line 3

def application
  @application
end

- (Object) context

Returns the value of attribute context



3
4
5
# File 'lib/fb_graph/achievement.rb', line 3

def context
  @context
end

- (Object) data

Returns the value of attribute data



3
4
5
# File 'lib/fb_graph/achievement.rb', line 3

def data
  @data
end

- (Object) description

Returns the value of attribute description



3
4
5
# File 'lib/fb_graph/achievement.rb', line 3

def description
  @description
end

- (Object) display_order

Returns the value of attribute display_order



3
4
5
# File 'lib/fb_graph/achievement.rb', line 3

def display_order
  @display_order
end

- (Object) image

Returns the value of attribute image



3
4
5
# File 'lib/fb_graph/achievement.rb', line 3

def image
  @image
end

- (Object) images

Returns the value of attribute images



3
4
5
# File 'lib/fb_graph/achievement.rb', line 3

def images
  @images
end

- (Object) points

Returns the value of attribute points



3
4
5
# File 'lib/fb_graph/achievement.rb', line 3

def points
  @points
end

- (Object) title

Returns the value of attribute title



3
4
5
# File 'lib/fb_graph/achievement.rb', line 3

def title
  @title
end

- (Object) type

Returns the value of attribute type



3
4
5
# File 'lib/fb_graph/achievement.rb', line 3

def type
  @type
end

- (Object) updated_time

Returns the value of attribute updated_time



3
4
5
# File 'lib/fb_graph/achievement.rb', line 3

def updated_time
  @updated_time
end

- (Object) url

Returns the value of attribute url



3
4
5
# File 'lib/fb_graph/achievement.rb', line 3

def url
  @url
end

Instance Method Details

- (Object) destroy(options = {})



39
40
41
42
# File 'lib/fb_graph/achievement.rb', line 39

def destroy(options = {})
  options[:access_token] ||= self.access_token
  application.unregister_achievement!(url, options)
end