Class: String
- Defined in:
- lib/strongspace/helpers.rb,
lib/strongspace/helpers.rb,
lib/strongspace/helpers.rb,
lib/strongspace/helpers.rb,
lib/strongspace/helpers.rb
Instance Method Summary collapse
- #camelize ⇒ Object
- #ends_with?(str) ⇒ Boolean
- #shellescape ⇒ Object
- #starts_with?(str) ⇒ Boolean
- #underscore ⇒ Object
Instance Method Details
#camelize ⇒ Object
323 324 325 |
# File 'lib/strongspace/helpers.rb', line 323 def camelize self.split(/[^a-z0-9]/i).map{|w| w.capitalize}.join end |
#ends_with?(str) ⇒ Boolean
305 306 307 308 309 |
# File 'lib/strongspace/helpers.rb', line 305 def ends_with?(str) str = str.to_str tail = self[-str.length, str.length] tail == str end |
#shellescape ⇒ Object
315 316 317 |
# File 'lib/strongspace/helpers.rb', line 315 def shellescape empty? ? "''" : gsub(/([^A-Za-z0-9_\-.,:\/@\n])/n, '\\\\\\1').gsub(/\n/, "'\n'") end |
#starts_with?(str) ⇒ Boolean
295 296 297 298 299 |
# File 'lib/strongspace/helpers.rb', line 295 def starts_with?(str) str = str.to_str head = self[0, str.length] head == str end |
#underscore ⇒ Object
331 332 333 |
# File 'lib/strongspace/helpers.rb', line 331 def underscore self.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').tr("-", "_").downcase end |