Class: FBScrape::Comment
- Inherits:
-
Object
- Object
- FBScrape::Comment
- Defined in:
- lib/fb_scrape/comment.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#from_id ⇒ Object
Returns the value of attribute from_id.
-
#from_name ⇒ Object
Returns the value of attribute from_name.
-
#id ⇒ Object
Returns the value of attribute id.
-
#message ⇒ Object
Returns the value of attribute message.
-
#page_id ⇒ Object
Returns the value of attribute page_id.
-
#replies ⇒ Object
Returns the value of attribute replies.
Instance Method Summary collapse
- #has_more_replies? ⇒ Boolean
-
#initialize(payload, access_token = nil, page_id = nil) ⇒ Comment
constructor
A new instance of Comment.
- #is_page_response? ⇒ Boolean
- #load_all_replies(limit = nil) ⇒ Object
- #load_replies(access_token = nil) ⇒ Object
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(payload, access_token = nil, page_id = nil) ⇒ Comment
Returns a new instance of Comment.
7 8 9 10 11 12 |
# File 'lib/fb_scrape/comment.rb', line 7 def initialize(payload, access_token=nil, page_id=nil) @replies = [] @access_token = access_token @page_id = page_id load_from_payload payload end |
Instance Attribute Details
#created_at ⇒ Object
Returns the value of attribute created_at.
5 6 7 |
# File 'lib/fb_scrape/comment.rb', line 5 def created_at @created_at end |
#from_id ⇒ Object
Returns the value of attribute from_id.
5 6 7 |
# File 'lib/fb_scrape/comment.rb', line 5 def from_id @from_id end |
#from_name ⇒ Object
Returns the value of attribute from_name.
5 6 7 |
# File 'lib/fb_scrape/comment.rb', line 5 def from_name @from_name end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/fb_scrape/comment.rb', line 5 def id @id end |
#message ⇒ Object
Returns the value of attribute message.
5 6 7 |
# File 'lib/fb_scrape/comment.rb', line 5 def @message end |
#page_id ⇒ Object
Returns the value of attribute page_id.
5 6 7 |
# File 'lib/fb_scrape/comment.rb', line 5 def page_id @page_id end |
#replies ⇒ Object
Returns the value of attribute replies.
5 6 7 |
# File 'lib/fb_scrape/comment.rb', line 5 def replies @replies end |
Instance Method Details
#has_more_replies? ⇒ Boolean
24 25 26 |
# File 'lib/fb_scrape/comment.rb', line 24 def has_more_replies? @page_info && next_cursor end |
#is_page_response? ⇒ Boolean
14 15 16 |
# File 'lib/fb_scrape/comment.rb', line 14 def is_page_response? @page_id == @from_id end |
#load_all_replies(limit = nil) ⇒ Object
28 29 30 31 32 |
# File 'lib/fb_scrape/comment.rb', line 28 def load_all_replies(limit=nil) while has_more_replies? && is_below_limit?(limit) do load_more_replies end end |
#load_replies(access_token = nil) ⇒ Object
18 19 20 21 22 |
# File 'lib/fb_scrape/comment.rb', line 18 def load_replies access_token=nil @access_token = access_token if access_token url = "https://graph.facebook.com/v#{FBScrape::GRAPH_VERSION}/#{@id}/comments?access_token=#{@access_token}" load_from_url url end |
#to_json(*args) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fb_scrape/comment.rb', line 34 def to_json(*args) JSON.pretty_generate({ id: @id, created_at: @created_at, from_name: @from_name, from_id: @from_id, page_id: @page_id, message: @message }) end |