module GPhoto2::Camera::Configuration
Overview
Provides access to camera configuration.
Direct including types
Defined in:
gphoto2/camera/configuration.crInstance Method Summary
-
#<<(widget : CameraWidget::Base) : self
iso = camera[:iso].as_radio iso.value = iso.choices.first camera << iso
-
#[](key : String | Symbol) : CameraWidget::Base
Returns the attribute identified by key.
-
#[]=(key : String | Symbol, value)
Updates the attribute identified by key with the specified value.
-
#[]?(key : String | Symbol) : CameraWidget::Base | Nil
Returns the attribute identified by key.
-
#config : Hash(String, CameraWidget::Base)
Returns flattened
Hash
of camera attributes. -
#dirty?
Returns
true
if any attributes have unsaved changes. -
#preserving_config(keys : Enumerable(String | Symbol) | Nil = nil, &) : Nil
Preserves config for a block call.
-
#reload : Nil
Reloads camera configuration.
-
#save : Bool
Updates the configuration on the camera.
-
#update(attributes) : Bool
Updates camera attributes from the given
Hash
,NamedTuple
or keyword arguments (**kwargs
) and saves the configuration. -
#window : CameraWidget::Window
Returns camera root configuration widget.
Instance Method Detail
iso = camera[:iso].as_radio
iso.value = iso.choices.first
camera << iso
Returns the attribute identified by key.
See: #config
camera[:whitebalance].to_s # => "Automatic"
camera["whitebalance"].to_s # => "Automatic"
Updates the attribute identified by key with the specified value.
This marks the configuration as "dirty", meaning a call to #save
is
needed to actually update the configuration on the camera.
camera["iso"] = 800
camera["f-number"] = "f/2.8"
camera["shutterspeed2"] = "1/60"
Returns the attribute identified by key.
See: #config
camera[:whitebalance].to_s # => "Automatic"
camera["whitebalance"].to_s # => "Automatic"
Returns flattened Hash
of camera attributes.
# List camera configuration keys.
camera.config.keys # => ["autofocusdrive", "manualfocusdrive", "controlmode", ...]
Returns true
if any attributes have unsaved changes.
camera.dirty? # => false
camera[:iso] = 400
camera.dirty? # => true
Preserves config for a block call.
# Original values
camera[:aperture] # => 4
camera[:iso] # => 400
# Capture photo with different settings,
# while preserving original values
camera.preserving_config do
1.upto(3) do |i|
camera.update({
aperture: 8,
iso: 200 * i,
})
file = camera.capture
file.save
end
end
# Original values are being preserved
camera[:aperture] # => 4
camera[:iso] # => 400
Reloads camera configuration.
All unsaved changes will be lost.
camera[:iso] # => 800
camera[:iso] = 200
camera.reload
camera[:iso] # => 800
Updates the configuration on the camera.
camera[:iso] = 800
camera.save # => true
camera.save # => false (nothing to update)
Updates camera attributes from the given
Hash
, NamedTuple
or keyword arguments (**kwargs
)
and saves the configuration.
camera[:iso] # => 800
camera[:shutterspeed2] # => "1/30"
# **kwargs
camera.update(iso: 400, shutterspeed2: "1/60")
# NamedTuple
camera.update({iso: 400, shutterspeed2: "1/60"})
# Hash
camera.update({"iso" => 400, "shutterspeed2" => "1/60"})
camera[:iso] # => 400
camera[:shutterspeed2] # => "1/60"