Class: Uploadcare::Api::FileList
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Uploadcare::Api::FileList
- Defined in:
- lib/uploadcare/resources/file_list.rb
Instance Method Summary collapse
-
#[](index) ⇒ Object
Array-like behavior.
- #go_to(index) ⇒ Object
-
#initialize(api, data) ⇒ FileList
constructor
A new instance of FileList.
-
#next_page ⇒ Object
List navigation.
- #previous_page ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(api, data) ⇒ FileList
Returns a new instance of FileList.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/uploadcare/resources/file_list.rb', line 6 def initialize api, data @api = api unless data["results"].nil? data["results"].map! do |file| Uploadcare::Api::File.new @api, file["uuid"], file end end super data end |
Instance Method Details
#[](index) ⇒ Object
Array-like behavior
19 20 21 |
# File 'lib/uploadcare/resources/file_list.rb', line 19 def [] index results[index] if defined?(:results) end |
#go_to(index) ⇒ Object
32 33 34 |
# File 'lib/uploadcare/resources/file_list.rb', line 32 def go_to index @api.file_list(index) unless index > pages end |
#next_page ⇒ Object
List navigation
28 29 30 |
# File 'lib/uploadcare/resources/file_list.rb', line 28 def next_page @api.file_list(page+1) unless send(:next).nil? end |
#previous_page ⇒ Object
36 37 38 |
# File 'lib/uploadcare/resources/file_list.rb', line 36 def previous_page @api.file_list(page-1) unless previous.nil? end |
#to_a ⇒ Object
23 24 25 |
# File 'lib/uploadcare/resources/file_list.rb', line 23 def to_a results if defined?(:results) end |