Class: GPhoto2::CameraFileInfo Abstract

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

Overview

This class is abstract.

Direct Known Subclasses

FileCameraFileInfo

Constant Summary

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

Attributes included from Struct

#ptr

Instance Method Summary collapse

Methods included from Struct

#to_ptr

Constructor Details

#initialize(ptr) ⇒ CameraFileInfo

Returns a new instance of CameraFileInfo.

Parameters:



8
9
10
# File 'lib/gphoto2/camera_file_info/camera_file_info.rb', line 8

def initialize(ptr)
  @ptr = ptr
end

Instance Method Details

#fieldsInteger

Returns a bit field of set info fields.

Returns:

  • (Integer)

    a bit field of set info fields



13
14
15
16
17
18
19
20
21
# File 'lib/gphoto2/camera_file_info/camera_file_info.rb', line 13

def fields
  fields = ptr[:fields]

  if fields.is_a?(Symbol)
    CameraFileInfoFields[fields]
  else
    fields
  end
end

#has_field?(field) ⇒ Boolean

return [Boolean] whether the given field is set

Returns:

  • (Boolean)


24
25
26
# File 'lib/gphoto2/camera_file_info/camera_file_info.rb', line 24

def has_field?(field)
  (fields & CameraFileInfoFields[field]) != 0
end

#sizeInteger?

Returns the size of the file in bytes.

Returns:

  • (Integer, nil)

    the size of the file in bytes



34
35
36
# File 'lib/gphoto2/camera_file_info/camera_file_info.rb', line 34

def size
  fetch(:size)
end

#statusCameraFileStatus?

Returns:



29
30
31
# File 'lib/gphoto2/camera_file_info/camera_file_info.rb', line 29

def status
  fetch(:status)
end

#typeString?

Returns the media type of the file.

Returns:

  • (String, nil)

    the media type of the file



39
40
41
42
# File 'lib/gphoto2/camera_file_info/camera_file_info.rb', line 39

def type
  type = fetch(:type)
  type ? type.to_s : nil
end