Class: GPhoto2::CameraFile

Inherits:
Object
  • Object
show all
Includes:
FFI::GPhoto2, Struct
Defined in:
lib/gphoto2/camera_file.rb

Constant Summary collapse

PREVIEW_FILENAME =

The preview data is assumed to be a jpg.

'capture_preview.jpg'.freeze

Constants included from FFI::GPhoto2

FFI::GPhoto2::CameraCaptureType, FFI::GPhoto2::CameraDriverStatus, FFI::GPhoto2::CameraEventType, FFI::GPhoto2::CameraFileAccessType, FFI::GPhoto2::CameraFileInfoFields, FFI::GPhoto2::CameraFileOperation, FFI::GPhoto2::CameraFilePermissions, FFI::GPhoto2::CameraFileStatus, FFI::GPhoto2::CameraFileType, FFI::GPhoto2::CameraFolderOperation, FFI::GPhoto2::CameraOperation, FFI::GPhoto2::CameraWidgetType, FFI::GPhoto2::GphotoDeviceType

Instance Attribute Summary collapse

Attributes included from Struct

#ptr

Instance Method Summary collapse

Methods included from Struct

#to_ptr

Constructor Details

#initialize(camera, folder = nil, name = nil) ⇒ CameraFile

Returns a new instance of CameraFile.

Parameters:

  • camera (GPhoto2::Camera)
  • folder (String) (defaults to: nil)
  • name (String) (defaults to: nil)


18
19
20
21
22
# File 'lib/gphoto2/camera_file.rb', line 18

def initialize(camera, folder = nil, name = nil)
  @camera = camera
  @folder, @name = folder, name
  new
end

Instance Attribute Details

#folderString (readonly)

Returns:

  • (String)


10
11
12
# File 'lib/gphoto2/camera_file.rb', line 10

def folder
  @folder
end

#nameString (readonly)

Returns:

  • (String)


13
14
15
# File 'lib/gphoto2/camera_file.rb', line 13

def name
  @name
end

Instance Method Details

#dataString

Returns:

  • (String)


41
42
43
# File 'lib/gphoto2/camera_file.rb', line 41

def data
  data_and_size.first
end

#deletevoid

This method returns an undefined value.



36
37
38
# File 'lib/gphoto2/camera_file.rb', line 36

def delete
  @camera.delete(self)
end

#infoGPhoto2::CameraFileInfo?

Returns:



51
52
53
# File 'lib/gphoto2/camera_file.rb', line 51

def info
  preview? ? nil : get_info
end

#preview?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/gphoto2/camera_file.rb', line 25

def preview?
  @folder.nil? && @name.nil?
end

#save(pathname = default_filename) ⇒ Integer

Returns the number of bytes written.

Parameters:

  • pathname (String) (defaults to: default_filename)

Returns:

  • (Integer)

    the number of bytes written



31
32
33
# File 'lib/gphoto2/camera_file.rb', line 31

def save(pathname = default_filename)
  File.binwrite(pathname, data)
end

#sizeInteger

Returns:

  • (Integer)


46
47
48
# File 'lib/gphoto2/camera_file.rb', line 46

def size
  data_and_size.last
end