Parent

Methods

Plist::StreamParser

Constants

TEXT
(Not documented)
XMLDECL_PATTERN
(Not documented)
DOCTYPE_PATTERN
(Not documented)
COMMENT_START
(Not documented)
COMMENT_END
(Not documented)

Public Class Methods

new( plist_data_or_file, listener ) click to toggle source

(Not documented)

    # File lib/plist/parser.rb, line 63
63:     def initialize( plist_data_or_file, listener )
64:       if plist_data_or_file.respond_to? :read
65:         @xml = plist_data_or_file.read
66:       elsif File.exists? plist_data_or_file
67:         @xml = File.read( plist_data_or_file )
68:       else
69:         @xml = plist_data_or_file
70:       end
71: 
72:       @listener = listener
73:     end

Public Instance Methods

parse() click to toggle source

(Not documented)

     # File lib/plist/parser.rb, line 82
 82:     def parse
 83:       plist_tags = PTag::mappings.keys.join('|')
 84:       start_tag  = /<(#{plist_tags})([^>]*)>/i
 85:       end_tag    = /<\/(#{plist_tags})[^>]*>/i
 86: 
 87:       require 'strscan'
 88: 
 89:       @scanner = StringScanner.new( @xml )
 90:       until @scanner.eos?
 91:         if @scanner.scan(COMMENT_START)
 92:           @scanner.scan(COMMENT_END)
 93:         elsif @scanner.scan(XMLDECL_PATTERN)
 94:         elsif @scanner.scan(DOCTYPE_PATTERN)
 95:         elsif @scanner.scan(start_tag)
 96:           @listener.tag_start(@scanner[1], nil)
 97:           if (@scanner[2] =~ /\/$/)
 98:             @listener.tag_end(@scanner[1])
 99:           end
100:         elsif @scanner.scan(TEXT)
101:           @listener.text(@scanner[1])
102:         elsif @scanner.scan(end_tag)
103:           @listener.tag_end(@scanner[1])
104:         else
105:           raise "Unimplemented element"
106:         end
107:       end
108:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.