Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more

In Files

  • xsd/codegen/classdef.rb

Parent

Included Modules

Class/Module Index [+]

Quicksearch

XSD::CodeGen::ClassDef

Public Class Methods

new(name, baseclass = nil) click to toggle 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) click to toggle 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) click to toggle 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() click to toggle 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