Class: Koala::Facebook::GraphCollection

Inherits:
Array
  • Object
show all
Defined in:
lib/koala/graph_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, api) ⇒ GraphCollection

Returns a new instance of GraphCollection.



18
19
20
21
22
# File 'lib/koala/graph_api.rb', line 18

def initialize(response, api)
  super response["data"]
  @paging = response["paging"]
  @api = api
end

Instance Attribute Details

#apiObject (readonly)

Returns the value of attribute api.



16
17
18
# File 'lib/koala/graph_api.rb', line 16

def api
  @api
end

#pagingObject (readonly)

This class is a light wrapper for collections returned from the Graph API.

It extends Array to allow direct access to the data colleciton which should allow it to drop in seamlessly.

It also allows access to paging information and the ability to get the next/previous page in the collection by calling next_page or previous_page.



15
16
17
# File 'lib/koala/graph_api.rb', line 15

def paging
  @paging
end

Instance Method Details

#parse_page_url(url) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/koala/graph_api.rb', line 42

def parse_page_url(url)
  match = url.match(/.com\/(.*)\?(.*)/)
  base = match[1]
  args = match[2]
  params = CGI.parse(args)
  new_params = {}
  params.each_pair do |key,value|
    new_params[key] = value.join ","
  end
  [base,new_params]
end