Class: Mogli::FetchingArray

Inherits:
Array
  • Object
show all
Defined in:
lib/mogli/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/mogli/fetching_array.rb', line 3

def classes
  @classes
end

#clientObject

Returns the value of attribute client.



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

def client
  @client
end

#next_urlObject

Returns the value of attribute next_url.



3
4
5
# File 'lib/mogli/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/mogli/fetching_array.rb', line 3

def previous_url
  @previous_url
end

Instance Method Details

#fetch_nextObject



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

def fetch_next
  return [] if next_url.nil? || next_url.empty?
  additions = client.get_and_map_url(next_url,classes)
  self.next_url = additions.next_url
  self.concat(additions)
  additions
end

#fetch_previousObject



13
14
15
16
17
18
19
# File 'lib/mogli/fetching_array.rb', line 13

def fetch_previous
  return [] if previous_url.nil? || previous_url.empty?
  additions = client.get_and_map_url(previous_url,classes)
  self.previous_url = additions.previous_url
  self.unshift(*additions)
  additions
end