Module: Duby::JavaSource::Helper
- Included in:
- ClassBuilder, MethodBuilder
- Defined in:
- lib/duby/jvm/source_generator/builder.rb
Instance Method Summary collapse
- #annotate(annotations) ⇒ Object
- #block(line = '') ⇒ Object
- #dedent ⇒ Object
- #indent ⇒ Object
- #init_value(type) ⇒ Object
- #print(*args) ⇒ Object
- #puts(*args) ⇒ Object
Instance Method Details
#annotate(annotations) ⇒ Object
127 128 129 130 131 |
# File 'lib/duby/jvm/source_generator/builder.rb', line 127 def annotate(annotations) annotations.each do |annotation| puts "@#{annotation.name}" end end |
#block(line = '') ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/duby/jvm/source_generator/builder.rb', line 107 def block(line='') puts line + " {" indent yield dedent puts "}" end |
#dedent ⇒ Object
103 104 105 |
# File 'lib/duby/jvm/source_generator/builder.rb', line 103 def dedent @out.dedent end |
#indent ⇒ Object
99 100 101 |
# File 'lib/duby/jvm/source_generator/builder.rb', line 99 def indent @out.indent end |
#init_value(type) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/duby/jvm/source_generator/builder.rb', line 115 def init_value(type) # TODO move this to types? case type when JVMTypes::Boolean 'false' when JVMTypes::PrimitiveType, JVMTypes::NarrowingType '0' else 'null' end end |
#print(*args) ⇒ Object
95 96 97 |
# File 'lib/duby/jvm/source_generator/builder.rb', line 95 def print(*args) @out.print(*args) end |
#puts(*args) ⇒ Object
91 92 93 |
# File 'lib/duby/jvm/source_generator/builder.rb', line 91 def puts(*args) @out.puts(*args) end |