Class: FBScrape::Post
- Inherits:
-
Object
- Object
- FBScrape::Post
- Defined in:
- lib/fb_scrape/post.rb
Instance Attribute Summary collapse
-
#comments ⇒ Object
Returns the value of attribute comments.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#id ⇒ Object
Returns the value of attribute id.
-
#link ⇒ Object
Returns the value of attribute link.
-
#message ⇒ Object
Returns the value of attribute message.
Class Method Summary collapse
Instance Method Summary collapse
- #has_more_comments? ⇒ Boolean
-
#initialize(payload, page_id = nil, token = nil) ⇒ Post
constructor
A new instance of Post.
- #load_all_comments(limit = nil) ⇒ Object
- #load_comments ⇒ Object
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(payload, page_id = nil, token = nil) ⇒ Post
Returns a new instance of Post.
7 8 9 10 11 12 13 14 15 |
# File 'lib/fb_scrape/post.rb', line 7 def initialize payload, page_id=nil, token=nil @comments = [] @page_id = page_id @token = token if payload load_from_payload(payload) end end |
Instance Attribute Details
#comments ⇒ Object
Returns the value of attribute comments.
5 6 7 |
# File 'lib/fb_scrape/post.rb', line 5 def comments @comments end |
#created_at ⇒ Object
Returns the value of attribute created_at.
5 6 7 |
# File 'lib/fb_scrape/post.rb', line 5 def created_at @created_at end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/fb_scrape/post.rb', line 5 def id @id end |
#link ⇒ Object
Returns the value of attribute link.
5 6 7 |
# File 'lib/fb_scrape/post.rb', line 5 def link @link end |
#message ⇒ Object
Returns the value of attribute message.
5 6 7 |
# File 'lib/fb_scrape/post.rb', line 5 def @message end |
Class Method Details
Instance Method Details
#has_more_comments? ⇒ Boolean
28 29 30 |
# File 'lib/fb_scrape/post.rb', line 28 def has_more_comments? @page_info && next_cursor end |
#load_all_comments(limit = nil) ⇒ Object
32 33 34 35 36 |
# File 'lib/fb_scrape/post.rb', line 32 def load_all_comments(limit=nil) while has_more_comments? && is_below_limit?(limit) do load_more_comments end end |
#load_comments ⇒ Object
23 24 25 26 |
# File 'lib/fb_scrape/post.rb', line 23 def load_comments url = "https://graph.facebook.com/v#{FBScrape::GRAPH_VERSION}/#{@id}/comments?access_token=#{@token}" load_from_url url end |
#to_json(*args) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/fb_scrape/post.rb', line 40 def to_json(*args) JSON.pretty_generate({ id: @id, created_at: @created_at, message: @message, link: @link }) end |