Sha256: c046390b67c7c040c9c93a9fdaee0ff24fa0464e1dac51d5a6826f794de48760

Contents?: true

Size: 731 Bytes

Versions: 1

Compression:

Stored size: 731 Bytes

Contents

require 'nokogiri'
# require 'open-uri'

module XsdReader

  class XML
    include Shared

    def xsd_from_uri
      # @xsd_from_uri ||= options[:xsd_uri].nil ? nil : open(options[:xsd_uri])
    end

    def xsd_from_file
      @xsd_from_file ||= options[:xsd_file].nil? ? nil : File.read(options[:xsd_file])
    end

    def xml
      @xsd_xml ||= options[:xsd_xml] || options[:xsd_data] || options[:xsd_raw] || xsd_from_file || xsd_from_uri
    end

    def doc
      @doc ||= Nokogiri.XML(xml)
    end

    def schema_node
      doc.root.name == 'schema' ? doc.root : nil
    end

    def schema
      node_to_object(schema_node)
    end

    def elements
      schema.elements
    end
  end # class XML

end # module XsdReader

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xsd-reader-0.0.1 lib/xsd_reader/xml.rb