Sha256: e94351a265862c267d2a6c9dbda91f9fdb3f0bc3171bb65d12a411ffe3bc357c

Contents?: true

Size: 364 Bytes

Versions: 8

Compression:

Stored size: 364 Bytes

Contents

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

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

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
arli-1.4.0 lib/arli/extensions.rb
arli-1.3.0 lib/arli/extensions.rb
arli-1.2.1 lib/arli/extensions.rb
arli-1.1.0 lib/arli/extensions.rb
arli-1.0.2 lib/arli/extensions.rb
arli-1.0.1 lib/arli/extensions.rb
arli-1.0.0 lib/arli/extensions.rb
arli-0.9.0 lib/arli/extensions.rb