Module: GPhoto2::Camera::Configuration
- Included in:
- GPhoto2::Camera
- Defined in:
- lib/gphoto2/camera/configuration.rb
Instance Method Summary collapse
-
#[](key) ⇒ GPhoto2::CameraWidget
The widget identified by ‘key`.
-
#[]=(key, value) ⇒ Object
Updates the attribute identified by ‘key` with the specified `value`.
-
#config ⇒ Hash<String,GPhoto2::CameraWidget>
A flat map of camera configuration widgets.
-
#dirty? ⇒ Boolean
Whether attributes have been changed.
- #initialize(model, port) ⇒ Object
-
#reload ⇒ void
Reloads the camera configuration.
-
#save ⇒ Boolean
Updates the configuration on the camera.
-
#update(attributes = {}) ⇒ Boolean
Updates the attributes of the camera from the given Hash and saves the configuration.
- #window ⇒ WindowCameraWidget
Instance Method Details
#[](key) ⇒ GPhoto2::CameraWidget
Returns the widget identified by ‘key`.
55 56 57 |
# File 'lib/gphoto2/camera/configuration.rb', line 55 def [](key) config[key.to_s] end |
#[]=(key, value) ⇒ Object
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.
72 73 74 75 76 77 |
# File 'lib/gphoto2/camera/configuration.rb', line 72 def []=(key, value) raise ArgumentError, "invalid key: #{key}" unless self[key] self[key].value = value @dirty = true value end |
#config ⇒ Hash<String,GPhoto2::CameraWidget>
Returns a flat map of camera configuration widgets.
24 25 26 |
# File 'lib/gphoto2/camera/configuration.rb', line 24 def config @config ||= window.flatten end |
#dirty? ⇒ Boolean
Returns whether attributes have been changed.
128 129 130 |
# File 'lib/gphoto2/camera/configuration.rb', line 128 def dirty? @dirty end |
#initialize(model, port) ⇒ Object
6 7 8 |
# File 'lib/gphoto2/camera/configuration.rb', line 6 def initialize(model, port) reset end |
#reload ⇒ void
This method returns an undefined value.
Reloads the camera configuration.
All unsaved changes will be lost.
43 44 45 46 47 |
# File 'lib/gphoto2/camera/configuration.rb', line 43 def reload @window.finalize if @window reset config end |
#save ⇒ Boolean
Updates the configuration on the camera.
89 90 91 92 93 94 |
# File 'lib/gphoto2/camera/configuration.rb', line 89 def save return false unless dirty? set_config @dirty = false true end |
#update(attributes = {}) ⇒ Boolean
Updates the attributes of the camera from the given Hash and saves the configuration.
110 111 112 113 114 115 116 |
# File 'lib/gphoto2/camera/configuration.rb', line 110 def update(attributes = {}) attributes.each do |key, value| self[key] = value end save end |
#window ⇒ WindowCameraWidget
11 12 13 |
# File 'lib/gphoto2/camera/configuration.rb', line 11 def window @window ||= get_config end |