Class: SecondHandler::FbSinglePost

Inherits:
Object
  • Object
show all
Includes:
FbDataHandler
Defined in:
lib/second_handler.rb

Constant Summary

Constants included from FbDataHandler

FbDataHandler::FACEBOOK_URL

Instance Method Summary collapse

Constructor Details

#initialize(access_token, post_id) ⇒ FbSinglePost

Returns a new instance of FbSinglePost.



11
12
13
14
# File 'lib/second_handler.rb', line 11

def initialize (access_token, post_id)
  @graph = Koala::Facebook::API.new(access_token)
  @post_id = post_id
end

Instance Method Details

#first_commentObject



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/second_handler.rb', line 28

def first_comment
  @comment = @graph.get_connections(@post_id, "comments",
    :limit=>1,
    :fields => ["from{name,id,picture}",
      "id",
      "message",
      "created_time",
      "like_count", 
    ]
  )
end

#get_commentObject



40
41
42
43
44
# File 'lib/second_handler.rb', line 40

def get_comment
  @comment.map do |single_comment|
    clean_comment(single_comment)
  end
end

#get_post_basicObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/second_handler.rb', line 15

def get_post_basic
  @basic = @graph.get_object(@post_id, :fields =>[
    "attachments{media,subattachments{media}}",
    "id",
    "message",
    "updated_time",
    "from{id,name,picture}",
    "comments.summary(1)",
    "likes.summary(1)"
  ])
  clean_post_content(@basic)
end

#next_page_commentObject



56
57
58
# File 'lib/second_handler.rb', line 56

def next_page_comment
  @comment = @comment.next_page
end

#next_page_comment_paramsObject



46
47
48
# File 'lib/second_handler.rb', line 46

def next_page_comment_params
  @comment.next_page_params
end

#previous_page_commentObject



60
61
62
# File 'lib/second_handler.rb', line 60

def previous_page_comment
  @comment = @comment.previous_page
end

#previous_page_comment_paramsObject



50
51
52
# File 'lib/second_handler.rb', line 50

def previous_page_comment_params
  @comment.previous_page_params
end