Class: RexleParser

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_s) ⇒ RexleParser

Returns a new instance of RexleParser.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/rexleparser.rb', line 62

def initialize(raw_s)

  super()
  s = raw_s.clone.strip
  return if s.empty?
  
  raw_xml, raw_instrctns = if s.lines.first =~ /<?xml/ then
    s.split(/(?=\?>\s*<\w)/,2).reverse
  else
    s
  end
  @instructions = raw_instrctns ? \
                            raw_instrctns.scan(/<\?([\w-]+) ([^\?]+)/) : []
  @doctype = s.slice!(/<!DOCTYPE html>\n?/) if s.lines.first =~ /<\!DOCTYPE/
  @to_a = reverse(parse_node(raw_xml.strip.reverse))

end

Instance Attribute Details

#doctypeObject (readonly)

Returns the value of attribute doctype.



60
61
62
# File 'lib/rexleparser.rb', line 60

def doctype
  @doctype
end

#instructionsObject (readonly)

Returns the value of attribute instructions.



60
61
62
# File 'lib/rexleparser.rb', line 60

def instructions
  @instructions
end

#to_aObject (readonly)

Returns the value of attribute to_a.



60
61
62
# File 'lib/rexleparser.rb', line 60

def to_a
  @to_a
end