Class: FbGraph::Message

Inherits:
Node
  • Object
show all
Includes:
Connections::Tags
Defined in:
lib/fb_graph/message.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#access_token, #endpoint, #identifier, #raw_attributes

Instance Method Summary collapse

Methods included from Connections::Tags

#tags

Methods inherited from Node

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

Methods included from Comparison

#==

Constructor Details

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

Returns a new instance of Message.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fb_graph/message.rb', line 10

def initialize(identifier, attributes = {})
  super
  @message = attributes[:message]
  if (from = attributes[:from])
    @from = User.new(from[:id], from)
  end
  @to = []
  if attributes[:to]
    Collection.new(attributes[:to]).each do |to|
      @to << User.new(to[:id], to)
    end
  end
  if attributes[:created_time]
    @created_time = Time.parse(attributes[:created_time]).utc
  end

  # cached connection
  cache_collection attributes, :tags
end

Instance Attribute Details

#created_timeObject

Returns the value of attribute created_time.



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

def created_time
  @created_time
end

#fromObject

Returns the value of attribute from.



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

def from
  @from
end

#messageObject

Returns the value of attribute message.



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

def message
  @message
end

#toObject

Returns the value of attribute to.



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

def to
  @to
end