examples/files.rb in box-api-0.1.9 vs examples/files.rb in box-api-0.2.0
- old
+ new
@@ -1,7 +1,8 @@
-# log in using the login example, so we don't have to duplicate code
$: << File.dirname(__FILE__) # for 1.9
+
+# log in using the login example, so we don't have to duplicate code
require 'login'
# get the root of the folder structure
root = @account.root
@@ -14,21 +15,18 @@
puts "Pick a folder number above to show: "
index = gets
begin
# grab the folder they selected
- # to_i or [] will throw an exception if the index is invalid or out of range respectively
folder = root.folders[index.to_i]
rescue
- # they picked an invalid folder!
+ # they picked a folder that broke our script!
puts "You picked an invalid folder, please try again."
exit
end
-# the folder they picked was valid
puts "Excellent choice, here are the contents of that folder"
-# show the selected folder
puts "FOLDER: #{ folder.name } (#{ folder.id })"
# loop through and show each of the sub files and folders
(folder.files + folder.folders).each do |item|
puts "\t#{ item.type.upcase }: #{ item.name } (#{ item.id })"