Class: RexleParser
- Inherits:
-
Object
- Object
- RexleParser
- Defined in:
- lib/rexleparser.rb
Instance Attribute Summary collapse
-
#doctype ⇒ Object
readonly
Returns the value of attribute doctype.
-
#instructions ⇒ Object
readonly
Returns the value of attribute instructions.
-
#to_a ⇒ Object
readonly
Returns the value of attribute to_a.
Instance Method Summary collapse
-
#initialize(raw_s) ⇒ RexleParser
constructor
A new instance of RexleParser.
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
#doctype ⇒ Object (readonly)
Returns the value of attribute doctype.
60 61 62 |
# File 'lib/rexleparser.rb', line 60 def doctype @doctype end |
#instructions ⇒ Object (readonly)
Returns the value of attribute instructions.
60 61 62 |
# File 'lib/rexleparser.rb', line 60 def instructions @instructions end |
#to_a ⇒ Object (readonly)
Returns the value of attribute to_a.
60 61 62 |
# File 'lib/rexleparser.rb', line 60 def to_a @to_a end |