Class: Arachni::Parser::SAX
- Defined in:
- lib/arachni/parser/sax.rb
Defined Under Namespace
Classes: Stop
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
Instance Method Summary collapse
- #attr(name, value) ⇒ Object
- #comment(value) ⇒ Object
- #end_element(name) ⇒ Object
-
#initialize(options = {}) ⇒ SAX
constructor
A new instance of SAX.
- #start_element(name) ⇒ Object
- #text(value) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ SAX
Returns a new instance of SAX.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/arachni/parser/sax.rb', line 20 def initialize( = {} ) super() @document = Document.new @stop_on_first = Set.new @stop_on_first.merge( [:stop_on_first] ) if [:stop_on_first] @current_node = @document end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
18 19 20 |
# File 'lib/arachni/parser/sax.rb', line 18 def document @document end |
Instance Method Details
#attr(name, value) ⇒ Object
51 52 53 54 55 |
# File 'lib/arachni/parser/sax.rb', line 51 def attr( name, value ) return if !@current_node.respond_to?( :attributes ) @current_node.attributes[name] = value end |
#comment(value) ⇒ Object
62 63 64 |
# File 'lib/arachni/parser/sax.rb', line 62 def comment( value ) @current_node << Nodes::Comment.new( value ) end |
#end_element(name) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/arachni/parser/sax.rb', line 44 def end_element( name ) # Finished parsing the desired element, abort. fail Stop if @stop @current_node = @current_node.parent end |
#start_element(name) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/arachni/parser/sax.rb', line 31 def start_element( name ) # We were instructed to stop on the first sight of the previous element # but came across this one before it closed. fail Stop if @stop @stop = stop?( name ) e = Nodes::Element.new( name ) e.document = @document @current_node << e @current_node = e end |