Class: Gio::Settings
- Inherits:
-
Object
- Object
- Gio::Settings
- Defined in:
- lib/gio2/settings.rb
Instance Method Summary collapse
-
#initialize(*args) ⇒ Settings
constructor
A new instance of Settings.
- #initialize_raw ⇒ Object
- #initialize_with_hash_args(options) ⇒ Object
- #set_value(key, value) ⇒ Object (also: #[]=)
- #set_value_raw ⇒ Object
Constructor Details
#initialize(*args) ⇒ Settings
Returns a new instance of Settings.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/gio2/settings.rb', line 21 def initialize(*args) if args.size == 1 if args[0].is_a?(String) initialize_raw(args[0]) else initialize_with_hash_args(args[0]) end elsif args.size == 2 schema_id = args[0] = args[1] path = [:path] || nil backend = [:backend] || nil if path && backend initialize_new_with_backend_and_path(schema_id, backend, path) elsif path initialize_new_with_path(schema_id, path) elsif backend initialize_new_with_backend(schema_id, backend) end elsif args.size == 3 initialize_new_full(*args) else = "must specify one of the following combinations: " + "schema_id, " + "options, " + "schema_id and options, " + "schema and backend and path " + "instead of: #{args.inspect}" raise ArgumentError, end end |
Instance Method Details
#initialize_raw ⇒ Object
19 |
# File 'lib/gio2/settings.rb', line 19 alias_method :initialize_raw, :initialize |
#initialize_with_hash_args(options) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/gio2/settings.rb', line 54 def initialize_with_hash_args() path = [:path] || nil schema_id = [:schema_id] || nil backend = [:backend] || nil schema = [:schema] || nil if schema_id if path && backend initialize_new_with_backend_and_path(schema_id, backend, path) elsif path initialize_new_with_path(schema_id, path) elsif backend initialize_new_with_backend(schema_id, backend) else initialize_raw(schema_id) end elsif schema initialize_new_full(schema, backend, path) else = "must specify one of the following combinations: " + ":schema_id, " + ":schema_id and :path, " + ":schema_id and :backend, " + ":schema_id and :backend and :path, " + ":schema, " + ":schema and :path, " + ":schema and :backend, " + "or :schema and :backend and :path " + "instead of: #{.inspect}" raise ArgumentError, end end |
#set_value(key, value) ⇒ Object Also known as: []=
88 89 90 91 92 |
# File 'lib/gio2/settings.rb', line 88 def set_value(key, value) schema_key = settings_schema.get_key(key) variant_value = GLib::Variant.new(value, schema_key.value_type) set_value_raw(key, variant_value) end |
#set_value_raw ⇒ Object
87 |
# File 'lib/gio2/settings.rb', line 87 alias_method :set_value_raw, :set_value |