Class: LaunchdTools::EnvironmentParser
- Inherits:
-
Object
- Object
- LaunchdTools::EnvironmentParser
- Defined in:
- lib/launchd_tools/environment_parser.rb
Instance Attribute Summary collapse
-
#element ⇒ Object
readonly
Returns the value of attribute element.
-
#xml_doc ⇒ Object
readonly
Returns the value of attribute xml_doc.
Instance Method Summary collapse
- #extract_env ⇒ Object
-
#initialize(xml_doc) ⇒ EnvironmentParser
constructor
A new instance of EnvironmentParser.
- #parse ⇒ Object
Constructor Details
#initialize(xml_doc) ⇒ EnvironmentParser
Returns a new instance of EnvironmentParser.
6 7 8 |
# File 'lib/launchd_tools/environment_parser.rb', line 6 def initialize(xml_doc) @xml_doc = xml_doc end |
Instance Attribute Details
#element ⇒ Object (readonly)
Returns the value of attribute element.
5 6 7 |
# File 'lib/launchd_tools/environment_parser.rb', line 5 def element @element end |
#xml_doc ⇒ Object (readonly)
Returns the value of attribute xml_doc.
5 6 7 |
# File 'lib/launchd_tools/environment_parser.rb', line 5 def xml_doc @xml_doc end |
Instance Method Details
#extract_env ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/launchd_tools/environment_parser.rb', line 14 def extract_env env = {} REXML::XPath.match(element, 'key').each do |environment_key| env[environment_key.text] = environment_key.next_sibling.next_sibling.text end env end |
#parse ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/launchd_tools/environment_parser.rb', line 22 def parse if element extract_env else {} end end |