Class: Relief::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/relief/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, options = {}, &block) ⇒ Parser

Returns a new instance of Parser.



8
9
10
# File 'lib/relief/parser.rb', line 8

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

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



6
7
8
# File 'lib/relief/parser.rb', line 6

def root
  @root
end

Instance Method Details

#parse(document) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/relief/parser.rb', line 12

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

  @root.parse(document)
end