Class: Guff::JavaSource::Annotation
- Inherits:
-
Object
- Object
- Guff::JavaSource::Annotation
- Defined in:
- lib/guff/java_source.rb
Instance Method Summary collapse
- #add_property(name, value) ⇒ Object
-
#initialize(type, value = nil) ⇒ Annotation
constructor
A new instance of Annotation.
- #write_properties_to(writer) ⇒ Object
- #write_to(writer) ⇒ Object
Constructor Details
#initialize(type, value = nil) ⇒ Annotation
Returns a new instance of Annotation.
211 212 213 214 215 |
# File 'lib/guff/java_source.rb', line 211 def initialize(type, value=nil) @type = type @properties = [] @properties << UnnamedProperty.new(value) unless value.nil? end |
Instance Method Details
#add_property(name, value) ⇒ Object
231 232 233 234 |
# File 'lib/guff/java_source.rb', line 231 def add_property(name, value) @properties << Property.new(name, value) self end |
#write_properties_to(writer) ⇒ Object
222 223 224 225 226 227 228 229 |
# File 'lib/guff/java_source.rb', line 222 def write_properties_to(writer) writer.append("(").indent.new_line joiner = proc { writer.append(",").new_line } writer.append_all(@properties, joiner) writer.outdent.new_line.append(")") end |
#write_to(writer) ⇒ Object
217 218 219 220 |
# File 'lib/guff/java_source.rb', line 217 def write_to(writer) writer.append("@#{@type}") write_properties_to(writer) unless @properties.empty? end |