Sha256: 64a350b929ae2550efb9573df86fd10191ae6a169f78b4282bcb20920bfe612e

Contents?: true

Size: 341 Bytes

Versions: 7

Compression:

Stored size: 341 Bytes

Contents

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

  def humanize(options = { capitalize: true })
    s = underscore.tr('_', ' ')
    s = s.capitalize if options[:capitalize]
    s
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
ilm-0.0.1 lib/string_overrides.rb
eulim-0.0.17 lib/string_overrides.rb
eulim-0.0.16 lib/string.rb
eulim-0.0.15 lib/string.rb
eulim-0.0.14 lib/string.rb
eulim-0.0.13 lib/string.rb
eulim-0.0.12 lib/string.rb