Module: XML
- Defined in:
- lib/Olib/xml.rb
Overview
XML utils
Class Method Summary collapse
- .cmd(cmd, timeout: 5, pattern:) ⇒ Object
- .lines(**opts, &block) ⇒ Object
- .match(cmd, patt, timeout: 5) ⇒ Object
- .tap ⇒ Object
- .xml_off ⇒ Object
- .xml_on ⇒ Object
Class Method Details
.cmd(cmd, timeout: 5, pattern:) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/Olib/xml.rb', line 20 def self.cmd(cmd, timeout: 5, pattern:) XML.tap do result = dothistimeout(cmd, timeout, pattern) return nil if result.nil? yield(result) ttl = Time.now + timeout while line = get yield(line) break if Time.now > ttl end end end |
.lines(**opts, &block) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/Olib/xml.rb', line 33 def self.lines(**opts, &block) XML.tap do while line = get result = block.call(line) break if result == :halt end end end |
.match(cmd, patt, timeout: 5) ⇒ Object
42 43 44 45 46 |
# File 'lib/Olib/xml.rb', line 42 def self.match(cmd, patt, timeout: 5) XML.tap do dothistimeout(cmd, timeout, patt) end end |
.tap ⇒ Object
13 14 15 16 17 18 |
# File 'lib/Olib/xml.rb', line 13 def self.tap xml_on result = yield xml_off result end |
.xml_off ⇒ Object
9 10 11 |
# File 'lib/Olib/xml.rb', line 9 def self.xml_off Script.current.want_downstream_xml = false end |
.xml_on ⇒ Object
5 6 7 |
# File 'lib/Olib/xml.rb', line 5 def self.xml_on Script.current.want_downstream_xml = true end |