Class: BrickFTP::RESTfulAPI::CountFolderContents
- Inherits:
-
Object
- Object
- BrickFTP::RESTfulAPI::CountFolderContents
- Includes:
- Command
- Defined in:
- lib/brick_ftp/restful_api/count_folder_contents.rb
Overview
Count folder contents
Instance Method Summary collapse
-
#call(path, recursive: false) ⇒ BrickFTP::Types::FolderContentsCount
Returns number of files and folders.
Methods included from Command
Instance Method Details
#call(path, recursive: false) ⇒ BrickFTP::Types::FolderContentsCount
Returns number of files and folders.
- Returns the combined total number of files and subfolders in a given folder recursively.
- Returns the number of files and folders, separately, located inside a given folder (non-recursively).
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/brick_ftp/restful_api/count_folder_contents.rb', line 25 def call(path, recursive: false) action = recursive ? 'count' : 'count_nrs' res = client.get("/api/rest/v1/folders/#{ERB::Util.url_encode(path)}?action=#{action}") if recursive BrickFTP::Types::FolderContentsCount.new(total: res['data']['count']) else BrickFTP::Types::FolderContentsCount.new(**res['data']['count'].symbolize_keys) end end |