Class: OXM
- Inherits:
-
Object
- Object
- OXM
- Defined in:
- lib/oxm.rb,
lib/oxm/object.rb,
lib/oxm/version.rb,
lib/oxm/sax_handler.rb
Defined Under Namespace
Classes: Object, SaxHandler
Constant Summary collapse
- VERSION =
"0.2.0"
Class Method Summary collapse
-
.from_xml(xml, loop_element, &block) ⇒ Array
Array of OXM::Objects.
Instance Method Summary collapse
-
#errors ⇒ Array
Error messages during the last from_xml call.
- #from_xml(loop_element, &block) ⇒ Object
-
#initialize(xml) ⇒ OXM
constructor
A new instance of OXM.
-
#warnings ⇒ Array
Warning messages during the last from_xml call.
Constructor Details
#initialize(xml) ⇒ OXM
Returns a new instance of OXM.
16 17 18 |
# File 'lib/oxm.rb', line 16 def initialize xml @xml = xml end |
Class Method Details
Instance Method Details
#errors ⇒ Array
Returns Error messages during the last from_xml call.
29 30 31 |
# File 'lib/oxm.rb', line 29 def errors @handler ? @handler.errors : [] end |
#from_xml(loop_element, &block) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/oxm.rb', line 21 def from_xml loop_element, &block return enum_for(:from_xml, loop_element, &block) unless block_given? @handler = OXM::SaxHandler.new(loop_element, &block) parser = Nokogiri::XML::SAX::Parser.new(@handler, 'UTF-8') parser.parse @xml end |
#warnings ⇒ Array
Returns Warning messages during the last from_xml call.
34 35 36 |
# File 'lib/oxm.rb', line 34 def warnings @handler ? @handler.warnings : [] end |