Class: FBScrape::Client
- Inherits:
-
Object
- Object
- FBScrape::Client
- Defined in:
- lib/fb_scrape/client.rb
Instance Attribute Summary collapse
-
#conversations ⇒ Object
Returns the value of attribute conversations.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#page_name ⇒ Object
Returns the value of attribute page_name.
-
#posts ⇒ Object
Returns the value of attribute posts.
Instance Method Summary collapse
- #can_load_more_conversations? ⇒ Boolean
- #has_more_conversations? ⇒ Boolean
- #has_more_posts? ⇒ Boolean
-
#initialize(page_name, token_secret, id = nil, limit = nil, load_on_init = true) ⇒ Client
constructor
A new instance of Client.
- #is_limited? ⇒ Boolean
- #is_under_limit? ⇒ Boolean
- #load(limit = nil) ⇒ Object
- #load_conversations(limit = nil) ⇒ Object
Constructor Details
#initialize(page_name, token_secret, id = nil, limit = nil, load_on_init = true) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fb_scrape/client.rb', line 7 def initialize(page_name, token_secret, id=nil, limit=nil, load_on_init=true) @page_name = page_name @token_secret = token_secret @id = id @posts = [] @conversations = [] @loaded_initial = false @loaded_initial_conversations = false @limit = limit @conversations_page_info = nil if @id && load_on_init load_initial_posts elsif !@id get_page_id end end |
Instance Attribute Details
#conversations ⇒ Object
Returns the value of attribute conversations.
5 6 7 |
# File 'lib/fb_scrape/client.rb', line 5 def conversations @conversations end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/fb_scrape/client.rb', line 5 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/fb_scrape/client.rb', line 5 def name @name end |
#page_name ⇒ Object
Returns the value of attribute page_name.
5 6 7 |
# File 'lib/fb_scrape/client.rb', line 5 def page_name @page_name end |
#posts ⇒ Object
Returns the value of attribute posts.
5 6 7 |
# File 'lib/fb_scrape/client.rb', line 5 def posts @posts end |
Instance Method Details
#can_load_more_conversations? ⇒ Boolean
46 47 48 |
# File 'lib/fb_scrape/client.rb', line 46 def can_load_more_conversations? !is_limited? || (@conversations.count < @limit.to_i && has_more_conversations?) end |
#has_more_conversations? ⇒ Boolean
50 51 52 |
# File 'lib/fb_scrape/client.rb', line 50 def has_more_conversations? @conversations_page_info && next_conversation_cursor end |
#has_more_posts? ⇒ Boolean
42 43 44 |
# File 'lib/fb_scrape/client.rb', line 42 def has_more_posts? @page_info && next_cursor end |
#is_limited? ⇒ Boolean
38 39 40 |
# File 'lib/fb_scrape/client.rb', line 38 def is_limited? !@limit.nil? end |
#is_under_limit? ⇒ Boolean
34 35 36 |
# File 'lib/fb_scrape/client.rb', line 34 def is_under_limit? !is_limited? || @posts.count < @limit.to_i end |
#load(limit = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/fb_scrape/client.rb', line 24 def load(limit=nil) load_initial_posts @limit = limit if limit != @limit while has_more_posts? && is_under_limit? do # load more posts load_more_posts end end |
#load_conversations(limit = nil) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/fb_scrape/client.rb', line 54 def load_conversations(limit=nil) @limit = limit if limit != @limit load_initial_conversations while has_more_conversations? && can_load_more_conversations? do load_more_conversations end end |