Class: String

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

Instance Method Summary collapse

Instance Method Details

#_chomp_nullObject



453
454
455
# File 'lib/mylibs.rb', line 453

def _chomp_null
    gsub(/\0.*/, '')
end

#double_quoteObject Also known as: dquote



443
444
445
# File 'lib/mylibs.rb', line 443

def double_quote
    '"' + self + '"'
end

#single_quoteObject Also known as: squote



448
449
450
# File 'lib/mylibs.rb', line 448

def single_quote
    "'" + self + "'"
end

#sql_escapeObject



463
464
465
466
# File 'lib/mylibs.rb', line 463

def sql_escape
    str = _chomp_null
    str.gsub(/\\/, '\&\&').gsub(/'/, "''")    #'
end

#sql_quoteObject



457
458
459
460
461
# File 'lib/mylibs.rb', line 457

def sql_quote
    str = _chomp_null
    return 'NULL' if str.empty?
    "'#{str.sql_escape}'"
end