Class: XSD::CodeGen::MethodDef

Inherits:
Object
  • Object
show all
Includes:
CommentDef, GenSupport
Defined in:
lib/xsd/codegen/methoddef.rb

Instance Attribute Summary collapse

Attributes included from CommentDef

#comment

Instance Method Summary collapse

Methods included from GenSupport

capitalize, constant?, #format, keyword?, safeconstname, safeconstname?, safemethodname, safemethodname?, safevarname, safevarname?, uncapitalize

Constructor Details

#initialize(name, *params) ⇒ MethodDef

Returns a new instance of MethodDef.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/xsd/codegen/methoddef.rb', line 23

def initialize(name, *params)
  klass, mname = name.split('.', 2)
  if mname.nil?
    mname, klass = klass, mname
  end
  unless safemethodname?(mname)
    raise ArgumentError.new("name '#{name}' seems to be unsafe")
  end
  if klass and klass != 'self' and !safeconstname(klass)
    raise ArgumentError.new("name '#{name}' seems to be unsafe")
  end
  @name = name
  @params = params
  @comment = nil
  @definition = yield if block_given?
end

Instance Attribute Details

#definitionObject

Returns the value of attribute definition.



21
22
23
# File 'lib/xsd/codegen/methoddef.rb', line 21

def definition
  @definition
end

Instance Method Details

#dumpObject



40
41
42
43
44
45
46
47
# File 'lib/xsd/codegen/methoddef.rb', line 40

def dump
  buf = ""
  buf << dump_comment if @comment
  buf << dump_method_def
  buf << dump_definition if @definition and !@definition.empty?
  buf << dump_method_def_end
  buf
end