Sha256: 406663f4f71a7e7f6226552d78cb865452ac31ae5a641253fce785e974720eb3

Contents?: true

Size: 364 Bytes

Versions: 95

Compression:

Stored size: 364 Bytes

Contents

# ********** Copyright 2016 Viacom, Inc. Apache 2.0 **********

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

  def underscore
    word = self.dup
    word.underscore!
    word
  end
end

Version data entries

95 entries across 95 versions & 1 rubygems

Version Path
roku_builder-4.21.2 lib/roku_builder/string.rb
roku_builder-4.21.1 lib/roku_builder/string.rb
roku_builder-4.21.0 lib/roku_builder/string.rb
roku_builder-4.20.0 lib/roku_builder/string.rb
roku_builder-4.19.0 lib/roku_builder/string.rb
roku_builder-4.18.0 lib/roku_builder/string.rb
roku_builder-4.17.1 lib/roku_builder/string.rb
roku_builder-4.17.0 lib/roku_builder/string.rb
roku_builder-4.16.1 lib/roku_builder/string.rb
roku_builder-4.15.2 lib/roku_builder/string.rb
roku_builder-4.15.1 lib/roku_builder/string.rb
roku_builder-4.15.0 lib/roku_builder/string.rb
roku_builder-4.14.1 lib/roku_builder/string.rb
roku_builder-4.14.0 lib/roku_builder/string.rb
roku_builder-4.12.3 lib/roku_builder/string.rb
roku_builder-4.13.0 lib/roku_builder/string.rb
roku_builder-4.12.2 lib/roku_builder/string.rb
roku_builder-4.12.1 lib/roku_builder/string.rb
roku_builder-4.12.0 lib/roku_builder/string.rb
roku_builder-4.11.5 lib/roku_builder/string.rb