Class: Chicago::Database::ValueParser Private

Inherits:
Object
  • Object
show all
Defined in:
lib/chicago/database/value_parser.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#parse(column, value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/chicago/database/value_parser.rb', line 4

def parse(column, value)
  if value.kind_of?(Array)
    return value.map {|v| parse(column, v) }
  end
  
  case column.column_type
  when :integer
    value.to_i
  when :date
    time = Chronic.parse(value, :endian_precedence => [:little, :middle])
    Date.new(time.year, time.month, time.day)
  when :datetime, :timestamp
    Chronic.parse(value, :endian_precedence => [:little, :middle])
  else
    value
  end
end