Class: EimXML::Parser

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

Defined Under Namespace

Modules: RE

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(src) ⇒ Parser

Returns a new instance of Parser.



24
25
26
27
# File 'lib/eim_xml/parser.rb', line 24

def initialize(src)
	@scanner = StringScanner.new(src)
	@scanner.scan(/\s*<\?.*?\?>\s*/)
end

Instance Attribute Details

#scannerObject (readonly)

Returns the value of attribute scanner.



15
16
17
# File 'lib/eim_xml/parser.rb', line 15

def scanner
  @scanner
end

Instance Method Details

#parseObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/eim_xml/parser.rb', line 29

def parse
	if @scanner.scan(RE::EMPTY_ELEMENT)
		parse_empty_element
	elsif @scanner.scan(RE::START_TAG)
		parse_start_tag
	elsif @scanner.scan(RE::STRING)
		parse_string
	else
		nil
	end
end