Class: Motion::SettingsBundle::Configuration
- Inherits:
-
Object
- Object
- Motion::SettingsBundle::Configuration
- Defined in:
- lib/motion-settings-bundle/configuration.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#preferences ⇒ Object
readonly
Returns the value of attribute preferences.
Instance Method Summary collapse
- #child(title, options = {}, &block) ⇒ Object
- #group(title, options = {}) ⇒ Object
-
#initialize(&block) ⇒ Configuration
constructor
A new instance of Configuration.
- #multivalue(title, options = {}) ⇒ Object
- #slider(title, options = {}) ⇒ Object
- #text(title, options = {}) ⇒ Object
- #title(title, options = {}) ⇒ Object
- #toggle(title, options = {}) ⇒ Object
Constructor Details
#initialize(&block) ⇒ Configuration
Returns a new instance of Configuration.
6 7 8 9 10 |
# File 'lib/motion-settings-bundle/configuration.rb', line 6 def initialize(&block) @preferences = [] @children = {} block.call(self) end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
4 5 6 |
# File 'lib/motion-settings-bundle/configuration.rb', line 4 def children @children end |
#preferences ⇒ Object (readonly)
Returns the value of attribute preferences.
4 5 6 |
# File 'lib/motion-settings-bundle/configuration.rb', line 4 def preferences @preferences end |
Instance Method Details
#child(title, options = {}, &block) ⇒ Object
52 53 54 55 |
# File 'lib/motion-settings-bundle/configuration.rb', line 52 def child(title, = {}, &block) @preferences << {"Title" => title, "File" => title, "Type" => "PSChildPaneSpecifier"}.merge() @children[title] = Configuration.new(&block) end |
#group(title, options = {}) ⇒ Object
46 47 48 49 50 |
# File 'lib/motion-settings-bundle/configuration.rb', line 46 def group(title, = {}) group = {"Title" => title, "Type" => "PSGroupSpecifier"} group["FooterText"] = [:footer] if [:footer] @preferences << group end |
#multivalue(title, options = {}) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/motion-settings-bundle/configuration.rb', line 25 def multivalue(title, = {}) preference(title, "PSMultiValueSpecifier", , { "Values" => [:values], "Titles" => [:titles].nil? ? [:values] : [:titles] }) end |
#slider(title, options = {}) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/motion-settings-bundle/configuration.rb', line 39 def (title, = {}) preference(title, "PSSliderSpecifier", , { "MinimumValue" => [:min], "MaximumValue" => [:max] }) end |
#text(title, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/motion-settings-bundle/configuration.rb', line 12 def text(title, = {}) preference(title, "PSTextFieldSpecifier", , { "IsSecure" => [:secure] || false, "KeyboardType" => [:keyboard] || "Alphabet", "AutocapitalizationType" => [:autocapitalization] || "Sentences", "AutocorrectionType" => [:autocorrection] || "Default" }) end |
#title(title, options = {}) ⇒ Object
21 22 23 |
# File 'lib/motion-settings-bundle/configuration.rb', line 21 def title(title, = {}) preference(title, "PSTitleValueSpecifier", ) end |
#toggle(title, options = {}) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/motion-settings-bundle/configuration.rb', line 32 def toggle(title, = {}) preference(title, "PSToggleSwitchSpecifier", , { "TrueValue" => true, "FalseValue" => false }) end |