Class: FGraph::Collection
- Inherits:
-
Array
- Object
- Array
- FGraph::Collection
- Defined in:
- lib/fgraph.rb
Overview
Collection objects for Graph response with array data.
Instance Attribute Summary collapse
-
#next_options ⇒ Object
readonly
Returns the value of attribute next_options.
-
#next_url ⇒ Object
Returns the value of attribute next_url.
-
#previous_options ⇒ Object
readonly
Returns the value of attribute previous_options.
-
#previous_url ⇒ Object
Returns the value of attribute previous_url.
Instance Method Summary collapse
- #first? ⇒ Boolean
-
#initialize(response) ⇒ Collection
constructor
Initialize Facebook response object with ‘data’ array value.
- #next? ⇒ Boolean
- #previous? ⇒ Boolean
- #url_options(url) ⇒ Object
Constructor Details
#initialize(response) ⇒ Collection
Initialize Facebook response object with ‘data’ array value.
31 32 33 34 35 36 37 38 |
# File 'lib/fgraph.rb', line 31 def initialize(response) return super unless response super(response['data']) paging = response['paging'] || {} self.next_url = paging['next'] self.previous_url = paging['previous'] end |
Instance Attribute Details
#next_options ⇒ Object (readonly)
Returns the value of attribute next_options.
28 29 30 |
# File 'lib/fgraph.rb', line 28 def @next_options end |
#next_url ⇒ Object
Returns the value of attribute next_url.
28 29 30 |
# File 'lib/fgraph.rb', line 28 def next_url @next_url end |
#previous_options ⇒ Object (readonly)
Returns the value of attribute previous_options.
28 29 30 |
# File 'lib/fgraph.rb', line 28 def @previous_options end |
#previous_url ⇒ Object
Returns the value of attribute previous_url.
28 29 30 |
# File 'lib/fgraph.rb', line 28 def previous_url @previous_url end |
Instance Method Details
#first? ⇒ Boolean
50 51 52 |
# File 'lib/fgraph.rb', line 50 def first? @previous_url.blank? and not @next_url.blank? end |
#next? ⇒ Boolean
54 55 56 |
# File 'lib/fgraph.rb', line 54 def next? not @next_url.blank? end |
#previous? ⇒ Boolean
58 59 60 |
# File 'lib/fgraph.rb', line 58 def previous? not @previous_url.blank? end |
#url_options(url) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/fgraph.rb', line 62 def (url) return unless url # Note: FB pass access token with '|' character, which cause URI::InvalidURIError uri = URI.parse(url.gsub('|', '%7C')) = {} uri.query.split('&').each do |param_set| param_set = param_set.split('=') [param_set[0]] = CGI.unescape(param_set[1]) end end |