Class: LaunchdTools::ProgramArgsParser
- Inherits:
-
Object
- Object
- LaunchdTools::ProgramArgsParser
- Defined in:
- lib/launchd_tools/program_args_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
-
#initialize(xml_doc) ⇒ ProgramArgsParser
constructor
A new instance of ProgramArgsParser.
- #parse ⇒ Object
Constructor Details
#initialize(xml_doc) ⇒ ProgramArgsParser
Returns a new instance of ProgramArgsParser.
6 7 8 |
# File 'lib/launchd_tools/program_args_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/program_args_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/program_args_parser.rb', line 5 def xml_doc @xml_doc end |
Instance Method Details
#parse ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/launchd_tools/program_args_parser.rb', line 10 def parse element = REXML::XPath.first(xml_doc, "plist/dict/key[text()='ProgramArguments']/following-sibling::array") if element args_strings = XPath.match(element, 'string') args_strings.map {|e| e.text } else program_string_element = REXML::XPath.first(xml_doc, "plist/dict/key[text()='Program']/following-sibling::string") [program_string_element.text] end end |