Class: Motion::SettingsBundle::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/motion-settings-bundle/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#childrenObject (readonly)

Returns the value of attribute children.



4
5
6
# File 'lib/motion-settings-bundle/configuration.rb', line 4

def children
  @children
end

#preferencesObject (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, options = {}, &block)
  @preferences << {"Title" => title, "File" => title, "Type" => "PSChildPaneSpecifier"}.merge(options)
  @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, options = {})
  group = {"Title" => title, "Type" => "PSGroupSpecifier"}
  group["FooterText"] = options[:footer] if options[: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, options = {})
  preference(title, "PSMultiValueSpecifier", options, {
    "Values" => options[:values],
    "Titles" => options[:titles].nil? ? options[:values] : options[:titles]
  })
end

#slider(title, options = {}) ⇒ Object



39
40
41
42
43
44
# File 'lib/motion-settings-bundle/configuration.rb', line 39

def slider(title, options = {})
  preference(title, "PSSliderSpecifier", options, {
    "MinimumValue" => options[:min],
    "MaximumValue" => options[: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, options = {})
  preference(title, "PSTextFieldSpecifier", options, {
    "IsSecure"               => options[:secure]             || false,
    "KeyboardType"           => options[:keyboard]           || "Alphabet",
    "AutocapitalizationType" => options[:autocapitalization] || "Sentences",
    "AutocorrectionType"     => options[:autocorrection]     || "Default"
  })
end

#title(title, options = {}) ⇒ Object



21
22
23
# File 'lib/motion-settings-bundle/configuration.rb', line 21

def title(title, options = {})
  preference(title, "PSTitleValueSpecifier", options)
end

#toggle(title, options = {}) ⇒ Object



32
33
34
35
36
37
# File 'lib/motion-settings-bundle/configuration.rb', line 32

def toggle(title, options = {})
  preference(title, "PSToggleSwitchSpecifier", options, {
    "TrueValue"  => true,
    "FalseValue" => false
  })
end