Class: LanguageParser::Prototype
- Inherits:
-
Object
- Object
- LanguageParser::Prototype
- Defined in:
- lib/cgialib/lp/Language.rb
Overview
class : Prototype
This class stores all of the information about a prototype
Direct Known Subclasses
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
The method arguments.
-
#class_name ⇒ Object
The class name.
-
#comments ⇒ Object
readonly
Comments associated with the method.
-
#method_name ⇒ Object
The name of the method.
-
#method_type ⇒ Object
The return type of the method.
-
#static ⇒ Object
True if the method is static.
-
#visibility ⇒ Object
Visibility of the method (public, private, etc.).
Instance Method Summary collapse
-
#add_argument(name, type = nil) ⇒ Object
add_argument( name, type ).
-
#add_comment(text) ⇒ Object
add_comment( text ).
-
#initialize ⇒ Prototype
constructor
initialize().
-
#to_s ⇒ Object
to_s().
Constructor Details
#initialize ⇒ Prototype
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
#arguments ⇒ Object (readonly)
The method arguments
228 229 230 |
# File 'lib/cgialib/lp/Language.rb', line 228 def arguments @arguments end |
#class_name ⇒ Object
The class name
225 226 227 |
# File 'lib/cgialib/lp/Language.rb', line 225 def class_name @class_name end |
#comments ⇒ Object (readonly)
Comments associated with the method
229 230 231 |
# File 'lib/cgialib/lp/Language.rb', line 229 def comments @comments end |
#method_name ⇒ Object
The name of the method
226 227 228 |
# File 'lib/cgialib/lp/Language.rb', line 226 def method_name @method_name end |
#method_type ⇒ Object
The return type of the method
227 228 229 |
# File 'lib/cgialib/lp/Language.rb', line 227 def method_type @method_type end |
#static ⇒ Object
True if the method is static
224 225 226 |
# File 'lib/cgialib/lp/Language.rb', line 224 def static @static end |
#visibility ⇒ Object
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_s ⇒ Object
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 |