class GPhoto2::CameraFolder
Attributes
path[R]
@return [String]
Public Class Methods
new(camera, path = '/')
click to toggle source
# File lib/gphoto2/camera_folder.rb, line 8 def initialize(camera, path = '/') @camera = camera @path = path end
Public Instance Methods
cd(name)
click to toggle source
@param [String] name the name of the directory @return [GPhoto2::CameraFolder]
# File lib/gphoto2/camera_folder.rb, line 39 def cd(name) case name when '.' self when '..' up else CameraFolder.new(@camera, File.join(@path, name)) end end
Also aliased as: /
files()
click to toggle source
@return [Array<GPhoto2::CameraFile>]
# File lib/gphoto2/camera_folder.rb, line 33 def files folder_list_files end
folders()
click to toggle source
@return [Array<GPhoto2::CameraFolder>]
# File lib/gphoto2/camera_folder.rb, line 28 def folders folder_list_folders end
name()
click to toggle source
@return [String]
# File lib/gphoto2/camera_folder.rb, line 19 def name if root? '/' else @path.rpartition('/').last end end
open(name)
click to toggle source
@param [String] name the filename of the file to open @return [GPhoto2::CameraFile]
# File lib/gphoto2/camera_folder.rb, line 53 def open(name) CameraFile.new(@camera, @path, name) end
root?()
click to toggle source
@return [Boolean]
# File lib/gphoto2/camera_folder.rb, line 14 def root? @path == '/' end
to_s()
click to toggle source
@return [String]
# File lib/gphoto2/camera_folder.rb, line 69 def to_s name end
up()
click to toggle source
@return [GPhoto2::CameraFolder]
# File lib/gphoto2/camera_folder.rb, line 58 def up if root? self else parent = @path.rpartition('/').first parent = '/' if parent.empty? CameraFolder.new(@camera, parent) end end
Private Instance Methods
folder_list_files()
click to toggle source
# File lib/gphoto2/camera_folder.rb, line 75 def folder_list_files list = CameraList.new rc = gp_camera_folder_list_files(@camera.ptr, @path, list.ptr, @camera.context.ptr) GPhoto2.check!(rc) list.to_a.map { |f| open(f.name) } end
folder_list_folders()
click to toggle source
# File lib/gphoto2/camera_folder.rb, line 84 def folder_list_folders list = CameraList.new rc = gp_camera_folder_list_folders(@camera.ptr, @path, list.ptr, @camera.context.ptr) GPhoto2.check!(rc) list.to_a.map { |f| cd(f.name) } end