module

GPhoto2::Camera::Configuration

Provides access to camera configuration.

Instance methods

<<(widget : CameraWidget::Base) : self
iso = camera[:iso].as_radio
iso.value = iso.choices.first
camera << iso
Source
[](key : String | Symbol) : CameraWidget::Base

Returns the attribute identified by key.

See: #config

camera[:whitebalance].to_s  # => "Automatic"
camera["whitebalance"].to_s # => "Automatic"
Source
[]=(key : String | Symbol, value)

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"
Source
[]?(key : String | Symbol) : CameraWidget::Base | Nil

Returns the attribute identified by key.

See: #config

camera[:whitebalance].to_s  # => "Automatic"
camera["whitebalance"].to_s # => "Automatic"
Source
config

Returns flattened Hash of camera attributes.

# List camera configuration keys.
camera.config.keys # => ["autofocusdrive", "manualfocusdrive", "controlmode", ...]

See also: #[] and #[]=

Source
dirty?

Returns true if any attributes have unsaved changes.

camera.dirty? # => false
camera[:iso] = 400
camera.dirty? # => true
Source
preserving_config(keys : Enumerable(String | Symbol) | Nil = nil, &) : Nil

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
Source
reload

Reloads camera configuration.

All unsaved changes will be lost.

camera[:iso] # => 800
camera[:iso] = 200
camera.reload
camera[:iso] # => 800
Source
save

Updates the configuration on the camera.

camera[:iso] = 800
camera.save # => true
camera.save # => false (nothing to update)
Source
update(attributes) : Bool

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"
Source
window

Returns camera root configuration widget.

Source