Class: LanguageParser::SQLField

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

Overview

class : SQLField

Represents a field in a table.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSQLField

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

#commentObject

Any comment associated with the field



36
37
38
# File 'lib/cgialib/lp/SQLLanguageScanner.rb', line 36

def comment
  @comment
end

#nameObject

The name of the field



31
32
33
# File 'lib/cgialib/lp/SQLLanguageScanner.rb', line 31

def name
  @name
end

#not_nullObject

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_keyObject

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

#typeObject

The type of the field



32
33
34
# File 'lib/cgialib/lp/SQLLanguageScanner.rb', line 32

def type
  @type
end

#uniqueObject

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_sObject

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