Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/mylibs.rb
Instance Method Summary collapse
- #_chomp_null ⇒ Object
- #double_quote ⇒ Object (also: #dquote)
- #single_quote ⇒ Object (also: #squote)
- #sql_escape ⇒ Object
- #sql_quote ⇒ Object
Instance Method Details
#_chomp_null ⇒ Object
453 454 455 |
# File 'lib/mylibs.rb', line 453 def _chomp_null gsub(/\0.*/, '') end |
#double_quote ⇒ Object Also known as: dquote
443 444 445 |
# File 'lib/mylibs.rb', line 443 def double_quote '"' + self + '"' end |
#single_quote ⇒ Object Also known as: squote
448 449 450 |
# File 'lib/mylibs.rb', line 448 def single_quote "'" + self + "'" end |
#sql_escape ⇒ Object
463 464 465 466 |
# File 'lib/mylibs.rb', line 463 def sql_escape str = _chomp_null str.gsub(/\\/, '\&\&').gsub(/'/, "''") #' end |
#sql_quote ⇒ Object
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 |