Class: LanguageParser::Prototype

Inherits:
Object
  • Object
show all
Defined in:
lib/cgialib/lp/Language.rb

Overview

class : Prototype

This class stores all of the information about a prototype

Direct Known Subclasses

JavaPrototype

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePrototype

initialize()

Constructs the Prototype object



211
212
213
214
215
216
217
218
219
220
221
# File 'lib/cgialib/lp/Language.rb', line 211

def initialize()
  
  @class_name = nil
  @method_name = nil
  @method_type = nil
  @arguments = []
  @comments = []
  @static = false
  @visibility = nil
  
end

Instance Attribute Details

#argumentsObject (readonly)

The method arguments



228
229
230
# File 'lib/cgialib/lp/Language.rb', line 228

def arguments
  @arguments
end

#class_nameObject

The class name



225
226
227
# File 'lib/cgialib/lp/Language.rb', line 225

def class_name
  @class_name
end

#commentsObject (readonly)

Comments associated with the method



229
230
231
# File 'lib/cgialib/lp/Language.rb', line 229

def comments
  @comments
end

#method_nameObject

The name of the method



226
227
228
# File 'lib/cgialib/lp/Language.rb', line 226

def method_name
  @method_name
end

#method_typeObject

The return type of the method



227
228
229
# File 'lib/cgialib/lp/Language.rb', line 227

def method_type
  @method_type
end

#staticObject

True if the method is static



224
225
226
# File 'lib/cgialib/lp/Language.rb', line 224

def static
  @static
end

#visibilityObject

Visibility of the method (public, private, etc.)



223
224
225
# File 'lib/cgialib/lp/Language.rb', line 223

def visibility
  @visibility
end

Instance Method Details

#add_argument(name, type = nil) ⇒ Object

add_argument( name, type )

name - The name of the argument type - The type of the argument

Adds an argument to the ordered argument list



254
255
256
257
258
259
260
261
# File 'lib/cgialib/lp/Language.rb', line 254

def add_argument( name, type = nil )
  
  arg = PrototypeArgument.new()
  arg.name = name
  arg.type = type
  @arguments.push( arg )
  
end

#add_comment(text) ⇒ Object

add_comment( text )

text - The text of the comment

Adds a comment to the prototype



269
270
271
272
273
274
275
# File 'lib/cgialib/lp/Language.rb', line 269

def add_comment( text )
  
  comment = PrototypeComment.new()
  comment.text = text 
  @comments.push( comment )
  
end

#to_sObject

to_s()

Returns the object pretty printed as a string



235
236
237
238
239
240
241
242
243
244
245
# File 'lib/cgialib/lp/Language.rb', line 235

def to_s()
  
  text = "#{method_name} - #{method_type} - "
  text += "( #{@arguments.map{ |arg| arg.to_s }.join(', ')} )"
  
  text += " - #{@visibility}" if ( @visibility )
  text += " - static" if ( @static )
  
  text
  
end