Class: HTML::StackingParser
- Inherits:
-
SGMLParser
- Object
- SGMLParser
- HTML::StackingParser
- Defined in:
- lib/html/stparser.rb
Direct Known Subclasses
Constant Summary
Constants inherited from SGMLParser
HTML::SGMLParser::Attrfind, HTML::SGMLParser::Charref, HTML::SGMLParser::Commentclose, HTML::SGMLParser::Commentopen, HTML::SGMLParser::Endbracket, HTML::SGMLParser::Endtagfind, HTML::SGMLParser::Endtagopen, HTML::SGMLParser::Entitydefs, HTML::SGMLParser::Entityref, HTML::SGMLParser::Incomplete, HTML::SGMLParser::Interesting, HTML::SGMLParser::Special, HTML::SGMLParser::Starttagopen, HTML::SGMLParser::Tagfind
Instance Attribute Summary
Attributes inherited from SGMLParser
Instance Method Summary collapse
-
#feed(string) ⇒ Object
Feed some more data to the parser.
- #last_tag ⇒ Object
- #parent_tag ⇒ Object
-
#parse_file_named(name) ⇒ Object
Open and parse the given file.
-
#stack ⇒ Object
accessors.
- #strip_whitespace=(flag) ⇒ Object
Methods inherited from SGMLParser
#close, #get_source, #goahead, #handle_charref, #handle_data_range, #handle_endtag, #handle_entityref, #handle_starttag, #has_context, #parse_comment, #parse_endtag, #parse_special, #parse_starttag, #report_unbalanced, #reset, #set_range, #setliteral, #setnomoretags, #unknown_endtag, #unknown_starttag
Instance Method Details
#feed(string) ⇒ Object
Feed some more data to the parser.
36 37 38 39 40 41 42 43 |
# File 'lib/html/stparser.rb', line 36 def feed(string) super while @saved.size > 0 saved = @saved @saved = '' super(saved) end end |
#last_tag ⇒ Object
18 |
# File 'lib/html/stparser.rb', line 18 def last_tag; @tagStack[-1] || 'html'; end |
#parent_tag ⇒ Object
20 |
# File 'lib/html/stparser.rb', line 20 def parent_tag; @tagStack[-2] || 'html'; end |
#parse_file_named(name) ⇒ Object
Open and parse the given file.
27 28 29 30 31 32 33 |
# File 'lib/html/stparser.rb', line 27 def parse_file_named(name) File.open(name) { |f| while bytes = f.read(65536) feed(bytes) end } end |
#stack ⇒ Object
accessors
16 |
# File 'lib/html/stparser.rb', line 16 def stack; @tagStack; end |
#strip_whitespace=(flag) ⇒ Object
22 |
# File 'lib/html/stparser.rb', line 22 def strip_whitespace=(flag); @stripWhitespace = flag; end |