File: rexml/dtd/notationdecl.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: REXML#2
  module: DTD#3
  class: NotationDecl#4
inherits from
  Child ( REXML )
has properties
constant: START #5
constant: START_RE #6
constant: PUBLIC #7
constant: SYSTEM #8
method: initialize #9
method: to_s #23
method: write / 2 #27
class method: parse_source #32

Class Hierarchy

Object ( Builtin-Module )
Child ( REXML )
  NotationDecl ( REXML::DTD ) #4

Code

   1  require "rexml/child"
   2  module REXML
   3    module DTD
   4      class NotationDecl < Child
   5        START = "<!NOTATION"
   6        START_RE = /^\s*#{START}/um
   7        PUBLIC = /^\s*#{START}\s+(\w[\w-]*)\s+(PUBLIC)\s+((["']).*?\4)\s*>/um
   8        SYSTEM = /^\s*#{START}\s+(\w[\w-]*)\s+(SYSTEM)\s+((["']).*?\4)\s*>/um
   9        def initialize src
  10          super()
  11          if src.match( PUBLIC )
  12            md = src.match( PUBLIC, true )
  13          elsif src.match( SYSTEM )
  14            md = src.match( SYSTEM, true )
  15          else
  16            raise ParseException.new( "error parsing notation: no matching pattern", src )
  17          end
  18          @name = md[1]
  19          @middle = md[2]
  20          @rest = md[3]
  21        end
  22 
  23        def to_s
  24          "<!NOTATION #@name #@middle #@rest>"
  25        end
  26 
  27        def write( output, indent )
  28          indent( output, indent )
  29          output << to_s
  30        end
  31 
  32        def NotationDecl.parse_source source, listener
  33          md = source.match( PATTERN_RE, true )
  34          thing = md[0].squeeze(" \t\n\r")
  35          listener.send inspect.downcase, thing 
  36        end
  37      end
  38    end
  39  end