Class: GPhoto2::Camera
- Inherits:
-
Object
- Object
- GPhoto2::Camera
- Includes:
- FFI::GPhoto2, Capture, Configuration, Event, Filesystem, Struct
- Defined in:
- lib/gphoto2/camera.rb,
lib/gphoto2/camera/event.rb,
lib/gphoto2/camera/capture.rb,
lib/gphoto2/camera/filesystem.rb,
lib/gphoto2/camera/configuration.rb
Defined Under Namespace
Modules: Capture, Configuration, Event, Filesystem
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 collapse
- #model ⇒ String readonly
- #port ⇒ String readonly
Class Method Summary collapse
-
.all ⇒ Array<GPhoto2::Camera>
A list of all available devices.
-
.first(&blk) ⇒ GPhoto2::Camera
The first detected camera.
- .open(model, port, &blk) ⇒ GPhoto2::Camera
-
.where(condition) ⇒ Array<GPhoto2::Camera>
Filters devices by a given condition.
Instance Method Summary collapse
- #abilities ⇒ GPhoto2::CameraAbilities
- #can?(operation) ⇒ Boolean
- #context ⇒ GPhoto2::Context
- #exit ⇒ void
- #finalize ⇒ void (also: #close)
-
#initialize(model, port) ⇒ Camera
constructor
A new instance of Camera.
- #port_info ⇒ GPhoto2::PortInfo
- #ptr ⇒ FFI::GPhoto::Camera
Methods included from Filesystem
Methods included from Event
Methods included from Configuration
#[], #[]=, #config, #dirty?, #reload, #save, #update, #window
Methods included from Capture
Methods included from Struct
Constructor Details
#initialize(model, port) ⇒ Camera
Returns a new instance of Camera.
108 109 110 111 |
# File 'lib/gphoto2/camera.rb', line 108 def initialize(model, port) super @model, @port = model, port end |
Instance Attribute Details
#model ⇒ String (readonly)
12 13 14 |
# File 'lib/gphoto2/camera.rb', line 12 def model @model end |
#port ⇒ String (readonly)
15 16 17 |
# File 'lib/gphoto2/camera.rb', line 15 def port @port end |
Class Method Details
.all ⇒ Array<GPhoto2::Camera>
Returns a list of all available devices.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/gphoto2/camera.rb', line 22 def self.all context = Context.new abilities = CameraAbilitiesList.new(context) cameras = abilities.detect entries = cameras.to_a.map do |entry| model, port = entry.name, entry.value Camera.new(model, port) end context.finalize entries end |
.first(&blk) ⇒ GPhoto2::Camera
Returns the first detected camera.
54 55 56 57 58 59 |
# File 'lib/gphoto2/camera.rb', line 54 def self.first(&blk) entries = all raise RuntimeError, 'no devices detected' if entries.empty? camera = entries.first autorelease(camera, &blk) end |
.open(model, port, &blk) ⇒ GPhoto2::Camera
81 82 83 84 |
# File 'lib/gphoto2/camera.rb', line 81 def self.open(model, port, &blk) camera = new(model, port) autorelease(camera, &blk) end |
.where(condition) ⇒ Array<GPhoto2::Camera>
Filters devices by a given condition.
Filter keys can be either ‘model` or `port`. Only the first filter is used.
100 101 102 103 104 |
# File 'lib/gphoto2/camera.rb', line 100 def self.where(condition) name = condition.keys.first pattern = condition.values.first all.select { |c| c.send(name).match(pattern) } end |
Instance Method Details
#abilities ⇒ GPhoto2::CameraAbilities
132 133 134 |
# File 'lib/gphoto2/camera.rb', line 132 def abilities @abilities || (init && @abilities) end |
#can?(operation) ⇒ Boolean
153 154 155 |
# File 'lib/gphoto2/camera.rb', line 153 def can?(operation) (abilities.operations & (CameraOperation[operation] || 0)) != 0 end |
#context ⇒ GPhoto2::Context
142 143 144 |
# File 'lib/gphoto2/camera.rb', line 142 def context @context ||= Context.new end |
#exit ⇒ void
This method returns an undefined value.
122 123 124 |
# File 'lib/gphoto2/camera.rb', line 122 def exit _exit end |
#finalize ⇒ void Also known as: close
This method returns an undefined value.
114 115 116 117 118 |
# File 'lib/gphoto2/camera.rb', line 114 def finalize @context.finalize if @context @window.finalize if @window unref if @ptr end |
#port_info ⇒ GPhoto2::PortInfo
137 138 139 |
# File 'lib/gphoto2/camera.rb', line 137 def port_info @port_info || (init && @port_info) end |
#ptr ⇒ FFI::GPhoto::Camera
127 128 129 |
# File 'lib/gphoto2/camera.rb', line 127 def ptr @ptr || (init && @ptr) end |