Class: Duby::JavaSource::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/duby/jvm/source_generator/builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, compiler) ⇒ Builder

Returns a new instance of Builder.



18
19
20
21
22
# File 'lib/duby/jvm/source_generator/builder.rb', line 18

def initialize(filename, compiler)
  @filename = filename
  @classes = []
  @compiler = compiler
end

Instance Attribute Details

#classesObject

Returns the value of attribute classes.



16
17
18
# File 'lib/duby/jvm/source_generator/builder.rb', line 16

def classes
  @classes
end

#compilerObject

Returns the value of attribute compiler.



16
17
18
# File 'lib/duby/jvm/source_generator/builder.rb', line 16

def compiler
  @compiler
end

#filenameObject

Returns the value of attribute filename.



16
17
18
# File 'lib/duby/jvm/source_generator/builder.rb', line 16

def filename
  @filename
end

#packageObject

Returns the value of attribute package.



16
17
18
# File 'lib/duby/jvm/source_generator/builder.rb', line 16

def package
  @package
end

Instance Method Details

#generateObject



36
37
38
39
40
# File 'lib/duby/jvm/source_generator/builder.rb', line 36

def generate
  @classes.each do |cls|
    yield cls.filename, cls
  end
end

#public_class(name, superclass = nil, *interfaces) ⇒ Object



24
25
26
27
28
# File 'lib/duby/jvm/source_generator/builder.rb', line 24

def public_class(name, superclass=nil, *interfaces)
  cls = ClassBuilder.new(self, name, superclass, interfaces)
  @classes << cls
  cls
end

#public_interface(name, *interfaces) ⇒ Object



30
31
32
33
34
# File 'lib/duby/jvm/source_generator/builder.rb', line 30

def public_interface(name, *interfaces)
  cls = InterfaceBuilder.new(self, name, interfaces)
  @classes << cls
  cls
end