Class: LaunchDr::PropertyList
- Inherits:
-
Object
- Object
- LaunchDr::PropertyList
- Defined in:
- lib/launchdr/property_list.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #dump(path) ⇒ Object
-
#initialize(label = nil, elements = {}) ⇒ PropertyList
constructor
A new instance of PropertyList.
- #to_plist ⇒ Object
Constructor Details
#initialize(label = nil, elements = {}) ⇒ PropertyList
Returns a new instance of PropertyList.
9 10 11 12 |
# File 'lib/launchdr/property_list.rb', line 9 def initialize label = nil, elements = {} @elements = elements @elements['Label'] = label || "rb.launchdr.#{UUID.new.generate}" end |
Instance Attribute Details
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
7 8 9 |
# File 'lib/launchdr/property_list.rb', line 7 def elements @elements end |
Class Method Details
.load(filename) ⇒ Object
32 33 34 35 |
# File 'lib/launchdr/property_list.rb', line 32 def self.load filename elements = OSX::PropertyList.load File.new(File. filename, 'r') new elements[:label], elements end |
Instance Method Details
#[](key) ⇒ Object
14 15 16 |
# File 'lib/launchdr/property_list.rb', line 14 def [] key @elements[key.to_s] end |
#[]=(key, value) ⇒ Object
18 19 20 |
# File 'lib/launchdr/property_list.rb', line 18 def []= key, value @elements[key] = value end |
#dump(path) ⇒ Object
26 27 28 29 30 |
# File 'lib/launchdr/property_list.rb', line 26 def dump path out = File.new(File.(File.join(path, @elements['Label'] + '.plist')), 'w+') OSX::PropertyList.dump out, @elements out.close end |
#to_plist ⇒ Object
22 23 24 |
# File 'lib/launchdr/property_list.rb', line 22 def to_plist @elements.to_plist end |