Class: PSQL::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/psql/column.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, raw_type, modifiers = nil) ⇒ Column

Returns a new instance of Column.



6
7
8
# File 'lib/psql/column.rb', line 6

def initialize( name, raw_type, modifiers=nil )
  @name, @raw_type, @modifiers = name, raw_type, modifiers
end

Instance Attribute Details

#modifiersObject (readonly)

Returns the value of attribute modifiers.



9
10
11
# File 'lib/psql/column.rb', line 9

def modifiers
  @modifiers
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/psql/column.rb', line 9

def name
  @name
end

#raw_typeObject (readonly)

Returns the value of attribute raw_type.



9
10
11
# File 'lib/psql/column.rb', line 9

def raw_type
  @raw_type
end

Instance Method Details

#typeObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/psql/column.rb', line 13

def type
  case raw_type
  when 'integer'
    :integer
  when 'double precision'
    :float
  when 'boolean'
    :boolean
  when /^character varying/
    :string
  when 'text'
    :text
  when 'date'
    :date
  when 'timestamp without time zone'
    :datetime
  end
end