Sha256: f32cffd994361eec5ac169f6393bc9c08a53a8f5980c4ecd46c52b52e91ae86f

Contents?: true

Size: 503 Bytes

Versions: 2

Compression:

Stored size: 503 Bytes

Contents

gem 'nokogiri', '~> 1.3.3'
require 'nokogiri'

module Relief
  class Error < StandardError ; end
  class ParseError < Error ; end

  class Parser
    attr_reader :root

    def initialize(name=nil, options={}, &block)
      @root = Element.new(name, options, &block)
    end

    def parse(document)
      unless document.is_a?(Nokogiri::XML::NodeSet)
        document = Nokogiri::XML(document.to_s)
      end

      raise ParseError if document.root.nil?

      @root.parse(document)
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
tylerhunt-relief-0.0.5 lib/relief/parser.rb
relief-0.0.5 lib/relief/parser.rb