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

In Files

  • xsd/codegen/moduledef.rb

Class/Module Index [+]

Quicksearch

XSD::CodeGen::ModuleDef

Public Class Methods

new(name) click to toggle source
 
               # File xsd/codegen/moduledef.rb, line 22
def initialize(name)
  @name = name
  @comment = nil
  @const = []
  @code = []
  @requirepath = []
  @methoddef = []
end
            

Public Instance Methods

add_method(m, visibility = :public) click to toggle source
 
               # File xsd/codegen/moduledef.rb, line 60
def add_method(m, visibility = :public)
  @methoddef << [visibility, m]
end
            
def_code(code) click to toggle source
 
               # File xsd/codegen/moduledef.rb, line 42
def def_code(code)
  @code << code
end
            
def_const(const, value) click to toggle source
 
               # File xsd/codegen/moduledef.rb, line 35
def def_const(const, value)
  unless safeconstname?(const)
    raise ArgumentError.new("#{const} seems to be unsafe")
  end
  @const << [const, value]
end
            
def_method(name, *params) click to toggle source
 
               # File xsd/codegen/moduledef.rb, line 46
def def_method(name, *params)
  add_method(MethodDef.new(name, *params) { yield if block_given? }, :public)
end
            
Also aliased as: def_publicmethod
def_privatemethod(name, *params) click to toggle source
 
               # File xsd/codegen/moduledef.rb, line 56
def def_privatemethod(name, *params)
  add_method(MethodDef.new(name, *params) { yield if block_given? }, :private)
end
            
def_protectedmethod(name, *params) click to toggle source
 
               # File xsd/codegen/moduledef.rb, line 51
def def_protectedmethod(name, *params)
  add_method(MethodDef.new(name, *params) { yield if block_given? },
    :protected)
end
            
def_publicmethod(name, *params) click to toggle source
Alias for: def_method
def_require(path) click to toggle source
 
               # File xsd/codegen/moduledef.rb, line 31
def def_require(path)
  @requirepath << path
end
            
dump() click to toggle source
 
               # File xsd/codegen/moduledef.rb, line 64
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_module_def
  spacer = false
  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 @methoddef.empty?
    buf << dump_emptyline if spacer
    spacer = true
    buf << dump_methods
  end
  buf << dump_module_def_end
  buf << dump_package_def_end(package) unless package.empty?
  buf.gsub(/^\s+$/, '')
end