Class: FbGraph::Notification

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

Instance Attribute Summary collapse

Attributes inherited from Node

#access_token, #endpoint, #identifier, #raw_attributes

Instance Method Summary collapse

Methods inherited from Node

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

Methods included from Comparison

#==

Constructor Details

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

Returns a new instance of Notification.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fb_graph/notification.rb', line 5

def initialize(identifier, attributes = {})
  super
  @title = attributes[:title]
  @message = attributes[:message]
  @link = attributes[:link]
  @unread = attributes[:unread] == 1
  if (application = attributes[:application])
    @application = Application.new(application[:id], application)
  end
  if (from = attributes[:from])
    @from = User.new(from[:id], from)
  end
  if (to = attributes[:to])
    @to = User.new(to[:id], to)
  end
  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

#applicationObject

Returns the value of attribute application.



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

def application
  @application
end

#created_timeObject

Returns the value of attribute created_time.



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

def created_time
  @created_time
end

#fromObject

Returns the value of attribute from.



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

def from
  @from
end

Returns the value of attribute link.



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

def link
  @link
end

#messageObject

Returns the value of attribute message.



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

def message
  @message
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

#toObject

Returns the value of attribute to.



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

def to
  @to
end

#unreadObject

Returns the value of attribute unread.



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

def unread
  @unread
end

#updated_timeObject

Returns the value of attribute updated_time.



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

def updated_time
  @updated_time
end

Instance Method Details

#read!(options = {}) ⇒ Object



28
29
30
# File 'lib/fb_graph/notification.rb', line 28

def read!(options = {})
  post options.merge(:unread => false)
end