Class: MysqlTypes
- Inherits:
-
Object
- Object
- MysqlTypes
- Defined in:
- app/mysql_types.rb
Overview
Maps MySQL data types to type descriptions the client can use.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ MysqlTypes
constructor
A new instance of MysqlTypes.
Constructor Details
#initialize ⇒ MysqlTypes
Returns a new instance of MysqlTypes.
5 6 7 |
# File 'app/mysql_types.rb', line 5 def initialize raise "can't instantiate #{self.class}" end |
Class Method Details
.map_to_google_charts_types(types) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/mysql_types.rb', line 10 def map_to_google_charts_types(types) types.map do |type| type = type.gsub(/\([^)]*\)/, '').strip case type when 'bool', 'boolean' 'boolean' when /double/, 'bigint', 'bit', 'dec', 'decimal', 'float', 'int', 'integer', 'mediumint', 'smallint', 'tinyint' 'number' when /char/, /binary/, /blob/, /text/, 'enum', 'set', /image/ 'string' when 'date', 'year' 'date' when 'datetime', 'timestamp' 'datetime' when 'time' 'timeofday' else puts "unexpected MySQL type: #{type}" 'string' end end end |