Class: LanguageParser::SQLField
- Inherits:
-
Object
- Object
- LanguageParser::SQLField
- Defined in:
- lib/cgialib/lp/SQLLanguageScanner.rb
Overview
class : SQLField
Represents a field in a table.
Instance Attribute Summary collapse
-
#comment ⇒ Object
Any comment associated with the field.
-
#name ⇒ Object
The name of the field.
-
#not_null ⇒ Object
True if the field is non-null.
-
#primary_key ⇒ Object
True if the field is the primary key.
-
#type ⇒ Object
The type of the field.
-
#unique ⇒ Object
True if the field is unique.
Instance Method Summary collapse
-
#initialize ⇒ SQLField
constructor
initialize().
-
#to_s ⇒ Object
to_s().
Constructor Details
#initialize ⇒ SQLField
initialize()
The constructor
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cgialib/lp/SQLLanguageScanner.rb', line 20 def initialize() @name = "" @type = "" @not_null = false @unique = false @primary_key = false @comment = "" end |
Instance Attribute Details
#comment ⇒ Object
Any comment associated with the field
36 37 38 |
# File 'lib/cgialib/lp/SQLLanguageScanner.rb', line 36 def comment @comment end |
#name ⇒ Object
The name of the field
31 32 33 |
# File 'lib/cgialib/lp/SQLLanguageScanner.rb', line 31 def name @name end |
#not_null ⇒ Object
True if the field is non-null
34 35 36 |
# File 'lib/cgialib/lp/SQLLanguageScanner.rb', line 34 def not_null @not_null end |
#primary_key ⇒ Object
True if the field is the primary key
35 36 37 |
# File 'lib/cgialib/lp/SQLLanguageScanner.rb', line 35 def primary_key @primary_key end |
#type ⇒ Object
The type of the field
32 33 34 |
# File 'lib/cgialib/lp/SQLLanguageScanner.rb', line 32 def type @type end |
#unique ⇒ Object
True if the field is unique
33 34 35 |
# File 'lib/cgialib/lp/SQLLanguageScanner.rb', line 33 def unique @unique end |
Instance Method Details
#to_s ⇒ Object
to_s()
Pretty prints the field as text
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/cgialib/lp/SQLLanguageScanner.rb', line 42 def to_s() attributes = [] attributes.push( "not null" ) if ( @not_null ) attributes.push( "unique" ) if ( @unique ) attributes.push( "primary key" ) if ( @primary_key ) "#{@name} - #{@type} - #{attributes.join(',')}" end |