Class: Joey::FetchingArray

Inherits:
Array
  • Object
show all
Defined in:
lib/joey/fetching_array.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#classesObject

Returns the value of attribute classes.



3
4
5
# File 'lib/joey/fetching_array.rb', line 3

def classes
  @classes
end

#clientObject

Returns the value of attribute client.



3
4
5
# File 'lib/joey/fetching_array.rb', line 3

def client
  @client
end

#countObject

Returns the value of attribute count.



3
4
5
# File 'lib/joey/fetching_array.rb', line 3

def count
  @count
end

#next_urlObject

Returns the value of attribute next_url.



3
4
5
# File 'lib/joey/fetching_array.rb', line 3

def next_url
  @next_url
end

#previous_urlObject

Returns the value of attribute previous_url.



3
4
5
# File 'lib/joey/fetching_array.rb', line 3

def previous_url
  @previous_url
end

Instance Method Details

#fetch_nextObject



5
6
7
8
9
10
11
12
13
# File 'lib/joey/fetching_array.rb', line 5

def fetch_next
  return [] if next_url.blank?
  # FIXME: following only returns a hash like {"id"=>"http://graph.facebook.com/100000637452380/feed"}
  # try to write a method in koala which can request absolute urls
  additions = client.get_and_map_url(next_url, classes)
  self.next_url = additions.next_url
  self.concat(additions)
  additions
end

#fetch_previousObject



15
16
17
18
19
20
21
22
23
# File 'lib/joey/fetching_array.rb', line 15

def fetch_previous
  return [] if previous_url.blank?
  # FIXME: following only returns a hash like {"id"=>"http://graph.facebook.com/100000637452380/feed"}
  # try to write a method in koala which can request absolute urls
  additions = client.get_and_map_url(previous_url, classes)
  self.previous_url = additions.previous_url
  self.unshift(*additions)
  additions
end