Class | XSD::CodeGen::ClassDef
In: | xsd/codegen/classdef.rb
Parent: | ModuleDef

### Methods

def_attr def_classvar dump new

### Included Modules

GenSupport

### Public Class methods

new(name, baseclass = nil)

[Source]

    # File xsd/codegen/classdef.rb, line 21
      def initialize(name, baseclass = nil)
        super(name)
        @baseclass = baseclass
        @classvar = []
        @attrdef = []
      end

### Public Instance methods

def_attr(attrname, writable = true, varname = nil)

[Source]

    # File xsd/codegen/classdef.rb, line 36
      def def_attr(attrname, writable = true, varname = nil)
        unless safevarname?(varname || attrname)
          raise ArgumentError.new("#{varname || attrname} seems to be unsafe")
        end
        @attrdef << [attrname, writable, varname]
      end

def_classvar(var, value)

[Source]

    # File xsd/codegen/classdef.rb, line 28
      def def_classvar(var, value)
        var = var.sub(/\A@@/, "")
        unless safevarname?(var)
          raise ArgumentError.new("#{var} seems to be unsafe")
        end
        @classvar << [var, value]
      end

dump()

[Source]

    # File xsd/codegen/classdef.rb, line 43
      def dump
        buf = ""
        unless @requirepath.empty?
          buf << dump_requirepath
        end
        buf << dump_emptyline unless buf.empty?
        package = @name.split(/::/)[0..-2]
        buf << dump_package_def(package) unless package.empty?
        buf << dump_comment if @comment
        buf << dump_class_def
        spacer = false
        unless @classvar.empty?
          spacer = true
          buf << dump_classvar
        end
        unless @const.empty?
          buf << dump_emptyline if spacer
          spacer = true
          buf << dump_const
        end
        unless @code.empty?
          buf << dump_emptyline if spacer
          spacer = true
          buf << dump_code
        end
        unless @attrdef.empty?
          buf << dump_emptyline if spacer
          spacer = true
          buf << dump_attributes
        end
        unless @methoddef.empty?
          buf << dump_emptyline if spacer
          spacer = true
          buf << dump_methods
        end
        buf << dump_class_def_end
        buf << dump_package_def_end(package) unless package.empty?
        buf.gsub(/^\s+$/, '')
      end

[Validate]