Class: FbGraph::Post

Inherits:
Node
  • Object
show all
Extended by:
Searchable
Includes:
Connections::Comments, Connections::Likes
Defined in:
lib/fb_graph/post.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#access_token, #endpoint, #identifier

Instance Method Summary collapse

Methods included from Searchable

search, search

Methods included from Connections::Comments

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

Methods inherited from Node

#connection, #destroy, fetch, #fetch

Methods included from Comparison

#==

Constructor Details

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

Returns a new instance of Post.



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
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fb_graph/post.rb', line 9

def initialize(identifier, attributes = {})
  super
  if (from = attributes[:from])
    @from = if from[:category]
      FbGraph::Page.new(from.delete(:id), from)
    else
      FbGraph::User.new(from.delete(:id), from)
    end
  end
  @to = []
  if attributes[:to]
    FbGraph::Collection.new(attributes[:to]).each do |to|
      @to << if to[:category]
        FbGraph::Page.new(to.delete(:id), to)
      else
        FbGraph::User.new(to.delete(:id), to)
      end
    end
  end
  @message     = attributes[:message]
  @picture     = attributes[:picture]
  @link        = attributes[:link]
  @name        = attributes[:name]
  @caption     = attributes[:caption]
  @description = attributes[:description]
  @source      = attributes[:source]
  @icon        = attributes[:icon]
  @attribution = attributes[:attribution]
  @actions     = attributes[:actions]
  @likes       = attributes[:likes]
  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

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

Instance Attribute Details

#actionsObject

Returns the value of attribute actions.



7
8
9
# File 'lib/fb_graph/post.rb', line 7

def actions
  @actions
end

#attributionObject

Returns the value of attribute attribution.



7
8
9
# File 'lib/fb_graph/post.rb', line 7

def attribution
  @attribution
end

#captionObject

Returns the value of attribute caption.



7
8
9
# File 'lib/fb_graph/post.rb', line 7

def caption
  @caption
end

#created_timeObject

Returns the value of attribute created_time.



7
8
9
# File 'lib/fb_graph/post.rb', line 7

def created_time
  @created_time
end

#descriptionObject

Returns the value of attribute description.



7
8
9
# File 'lib/fb_graph/post.rb', line 7

def description
  @description
end

#fromObject

Returns the value of attribute from.



7
8
9
# File 'lib/fb_graph/post.rb', line 7

def from
  @from
end

#iconObject

Returns the value of attribute icon.



7
8
9
# File 'lib/fb_graph/post.rb', line 7

def icon
  @icon
end

#likesObject

Returns the value of attribute likes.



7
8
9
# File 'lib/fb_graph/post.rb', line 7

def likes
  @likes
end

Returns the value of attribute link.



7
8
9
# File 'lib/fb_graph/post.rb', line 7

def link
  @link
end

#messageObject

Returns the value of attribute message.



7
8
9
# File 'lib/fb_graph/post.rb', line 7

def message
  @message
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/fb_graph/post.rb', line 7

def name
  @name
end

#pictureObject

Returns the value of attribute picture.



7
8
9
# File 'lib/fb_graph/post.rb', line 7

def picture
  @picture
end

#sourceObject

Returns the value of attribute source.



7
8
9
# File 'lib/fb_graph/post.rb', line 7

def source
  @source
end

#toObject

Returns the value of attribute to.



7
8
9
# File 'lib/fb_graph/post.rb', line 7

def to
  @to
end

#updated_timeObject

Returns the value of attribute updated_time.



7
8
9
# File 'lib/fb_graph/post.rb', line 7

def updated_time
  @updated_time
end