Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/arli/extensions.rb

Instance Method Summary collapse

Instance Method Details

#reformat_wrapped(width = 70, indent_with = 8) ⇒ Object



10
11
12
13
# File 'lib/arli/extensions.rb', line 10

def reformat_wrapped(width = 70, indent_with = 8)
  ind = (' ' * indent_with)
  (ind + self.gsub(/\s+/, ' ').gsub(/(.{1,#{width}})( |\Z)/, "\\1\n" + ind))
end

#underscoreObject



2
3
4
5
6
7
8
# File 'lib/arli/extensions.rb', line 2

def underscore
  self.gsub(/::/, '/').
      gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
      gsub(/([a-z\d])([A-Z])/, '\1_\2').
      tr('-', '_').
      downcase
end