Class: String

Inherits:
Object show all
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

Instance Method Details

#camelizeObject



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

Returns:

  • (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

#shellescapeObject



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

Returns:

  • (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

#underscoreObject



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