class String

Public Instance Methods

lower_camel() click to toggle source
# File lib/zan_tools/string.rb, line 6
def lower_camel
  gsub(/\A([A-Z])/){|e| $1.downcase }.gsub(/[_]([a-z])/){|e| $1.upcase}
end
to_jdbc() click to toggle source
# File lib/zan_tools/string.rb, line 14
def to_jdbc
  {
    'Long' => 'BIGINT',
    'String' => 'VARCHAR',
    'Date' => 'TIMESTAMP',
    'Integer' => 'INTEGER',
    'Double' => 'DOUBLE'
  }[self] || self.upcase
end
underscore() click to toggle source
# File lib/zan_tools/string.rb, line 2
def underscore
  self.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase
end
upper_camel() click to toggle source
# File lib/zan_tools/string.rb, line 10
def upper_camel
  gsub(/\A(.)/){|e| $1.upcase }.gsub(/[_]([a-z])/){|e| $1.upcase}
end
valid_type?() click to toggle source
# File lib/zan_tools/string.rb, line 24
def valid_type?
  %w{Long String Integer Date}.include?(camel)
end