Class: Koala::Facebook::GraphCollection

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, api) ⇒ GraphCollection

Returns a new instance of GraphCollection.



16
17
18
19
20
# File 'lib/koala/graph_collection.rb', line 16

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

Instance Attribute Details

#apiObject (readonly)

Returns the value of attribute api.



14
15
16
# File 'lib/koala/graph_collection.rb', line 14

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.



13
14
15
# File 'lib/koala/graph_collection.rb', line 13

def paging
  @paging
end

Instance Method Details

#parse_page_url(url) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/koala/graph_collection.rb', line 40

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