Class: XsdReader::XML
- Inherits:
-
Object
- Object
- XsdReader::XML
- Defined in:
- lib/xsd_reader/xml.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#[](*args) ⇒ Object
forwards most functions to schema.
- #doc ⇒ Object
- #elements ⇒ Object
- #imports ⇒ Object
-
#initialize(_opts = {}) ⇒ XML
constructor
A new instance of XML.
- #logger ⇒ Object
- #node ⇒ Object
- #schema ⇒ Object
- #schema_for_namespace(_ns) ⇒ Object
- #schema_node ⇒ Object
- #simple_types ⇒ Object
- #xml ⇒ Object
- #xsd_from_file ⇒ Object
- #xsd_from_uri ⇒ Object
Constructor Details
#initialize(_opts = {}) ⇒ XML
9 10 11 12 |
# File 'lib/xsd_reader/xml.rb', line 9 def initialize(_opts = {}) = _opts || {} raise "#{self.class.to_s}.new expects a hash parameter" if !.is_a?(Hash) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/xsd_reader/xml.rb', line 7 def end |
Instance Method Details
#[](*args) ⇒ Object
forwards most functions to schema
50 51 52 |
# File 'lib/xsd_reader/xml.rb', line 50 def [](*args) schema[*args] end |
#doc ⇒ Object
33 34 35 |
# File 'lib/xsd_reader/xml.rb', line 33 def doc @doc ||= Nokogiri.XML(xml) end |
#elements ⇒ Object
54 55 56 |
# File 'lib/xsd_reader/xml.rb', line 54 def elements schema.elements end |
#imports ⇒ Object
58 59 60 |
# File 'lib/xsd_reader/xml.rb', line 58 def imports schema.imports end |
#logger ⇒ Object
14 15 16 17 18 19 |
# File 'lib/xsd_reader/xml.rb', line 14 def logger return @logger if @logger @logger ||= [:logger] || Logger.new(STDOUT) @logger.level = Logger::WARN return @logger end |
#node ⇒ Object
37 38 39 |
# File 'lib/xsd_reader/xml.rb', line 37 def node nil end |
#schema ⇒ Object
45 46 47 |
# File 'lib/xsd_reader/xml.rb', line 45 def schema @schema ||= Schema.new(self..merge(:node => schema_node, :logger => logger)) end |
#schema_for_namespace(_ns) ⇒ Object
66 67 68 |
# File 'lib/xsd_reader/xml.rb', line 66 def schema_for_namespace(_ns) schema.schema_for_namespace(_ns) end |
#schema_node ⇒ Object
41 42 43 |
# File 'lib/xsd_reader/xml.rb', line 41 def schema_node doc.root.name == 'schema' ? doc.root : nil end |
#simple_types ⇒ Object
62 63 64 |
# File 'lib/xsd_reader/xml.rb', line 62 def simple_types schema.simple_types end |
#xml ⇒ Object
29 30 31 |
# File 'lib/xsd_reader/xml.rb', line 29 def xml @xsd_xml ||= [:xsd_xml] || [:xsd_data] || [:xsd_raw] || xsd_from_file || xsd_from_uri end |
#xsd_from_file ⇒ Object
25 26 27 |
# File 'lib/xsd_reader/xml.rb', line 25 def xsd_from_file @xsd_from_file ||= [:xsd_file].nil? ? nil : File.read([:xsd_file]) end |
#xsd_from_uri ⇒ Object
21 22 23 |
# File 'lib/xsd_reader/xml.rb', line 21 def xsd_from_uri # @xsd_from_uri ||= options[:xsd_uri].nil ? nil : open(options[:xsd_uri]) end |