Class: HTML::StackingParser

Inherits:
SGMLParser show all
Defined in:
lib/web/htmltools/stparser.rb

Overview

:nodoc: all

Constant Summary

Constants inherited from SGMLParser

SGMLParser::Attrfind, SGMLParser::Charref, SGMLParser::Commentclose, SGMLParser::Commentopen, SGMLParser::Endbracket, SGMLParser::Endtagopen, SGMLParser::Entitydefs, SGMLParser::Entityref, SGMLParser::Incomplete, SGMLParser::Interesting, SGMLParser::Special, SGMLParser::Starttagopen, SGMLParser::Tagfind

Instance Method Summary collapse

Methods inherited from SGMLParser

#close, #goahead, #handle_charref, #handle_endtag, #handle_entityref, #handle_starttag, #has_context, #parse_comment, #parse_endtag, #parse_special, #parse_starttag, #report_unbalanced, #reset, #setliteral, #setnomoretags, #unknown_endtag, #unknown_starttag

Instance Method Details

#feed(string) ⇒ Object

Feed some more data to the parser.



34
35
36
37
38
39
40
41
# File 'lib/web/htmltools/stparser.rb', line 34

def feed(string)
  super
  while @saved.size > 0
    saved = @saved
    @saved = ''
    super(saved)
  end
end

#last_tagObject



16
# File 'lib/web/htmltools/stparser.rb', line 16

def last_tag; @tagStack[-1] || 'html'; end

#parent_tagObject



18
# File 'lib/web/htmltools/stparser.rb', line 18

def parent_tag; @tagStack[-2] || 'html'; end

#parse_file_named(name) ⇒ Object

Open and parse the given file.



25
26
27
28
29
30
31
# File 'lib/web/htmltools/stparser.rb', line 25

def parse_file_named(name)
  File.open(name) { |f|
    while bytes = f.read(65536)
      feed(bytes)
    end
  }
end

#stackObject

accessors



14
# File 'lib/web/htmltools/stparser.rb', line 14

def stack; @tagStack; end

#strip_whitespace=(flag) ⇒ Object



20
# File 'lib/web/htmltools/stparser.rb', line 20

def strip_whitespace=(flag); @stripWhitespace = flag; end