Class: String

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

Instance Method Summary collapse

Instance Method Details

#camelize(first_letter_in_uppercase = true) ⇒ Object



77
78
79
# File 'lib/ext/string.rb', line 77

def camelize(first_letter_in_uppercase = true)
  Inflector.camelize(self, first_letter_in_uppercase)
end

#constantizeObject



73
74
75
# File 'lib/ext/string.rb', line 73

def constantize
  Inflector.constantize(self)
end

#dasherizeObject



85
86
87
# File 'lib/ext/string.rb', line 85

def dasherize
  Inflector.dasherize(self)
end

#demodulizeObject



89
90
91
# File 'lib/ext/string.rb', line 89

def demodulize
  Inflector.demodulize(self)
end

#foreign_key(separate_class_name_and_id_with_underscore = true) ⇒ Object



93
94
95
# File 'lib/ext/string.rb', line 93

def foreign_key(separate_class_name_and_id_with_underscore = true)
  Inflector.foreign_key(self, separate_class_name_and_id_with_underscore)
end

#ordinalizeObject



97
98
99
# File 'lib/ext/string.rb', line 97

def ordinalize  
  Inflector.ordinalize(self)
end

#underscoreObject



81
82
83
# File 'lib/ext/string.rb', line 81

def underscore
  Inflector.underscore(self)
end

#wrap(col = 80) ⇒ Object



101
102
103
104
# File 'lib/ext/string.rb', line 101

def wrap(col=80)
  # http://blog.macromates.com/2006/wrapping-text-with-regular-expressions/
  gsub(/(.{1,#{col}})( +|$\n?)|(.{1,#{col}})/, "\\1\\3\n") 
end