Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/mylibs.rb
Direct Known Subclasses
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
455 456 457 |
# File 'lib/mylibs.rb', line 455 def _chomp_null gsub(/\0.*/, '') end |
#double_quote ⇒ Object Also known as: dquote
445 446 447 |
# File 'lib/mylibs.rb', line 445 def double_quote '"' + self + '"' end |
#single_quote ⇒ Object Also known as: squote
450 451 452 |
# File 'lib/mylibs.rb', line 450 def single_quote "'" + self + "'" end |
#sql_escape ⇒ Object
465 466 467 468 |
# File 'lib/mylibs.rb', line 465 def sql_escape str = _chomp_null str.gsub(/\\/, '\&\&').gsub(/'/, "''") #' end |
#sql_quote ⇒ Object
459 460 461 462 463 |
# File 'lib/mylibs.rb', line 459 def sql_quote str = _chomp_null return 'NULL' if str.empty? "'#{str.sql_escape}'" end |