Class: LaunchdTools::ProgramArgsParser

Inherits:
Object
  • Object
show all
Defined in:
lib/launchd_tools/program_args_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#elementObject (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_docObject (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

#parseObject



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