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.11.4 lib/roku_builder/string.rb
roku_builder-4.11.3 lib/roku_builder/string.rb
roku_builder-4.11.2 lib/roku_builder/string.rb
roku_builder-4.11.1 lib/roku_builder/string.rb
roku_builder-4.11.0 lib/roku_builder/string.rb
roku_builder-4.10.1 lib/roku_builder/string.rb
roku_builder-4.10.0 lib/roku_builder/string.rb
roku_builder-4.9.5 lib/roku_builder/string.rb
roku_builder-4.9.4 lib/roku_builder/string.rb
roku_builder-4.9.3 lib/roku_builder/string.rb
roku_builder-4.9.2 lib/roku_builder/string.rb
roku_builder-4.9.1 lib/roku_builder/string.rb
roku_builder-4.9.0 lib/roku_builder/string.rb
roku_builder-4.8.2 lib/roku_builder/string.rb
roku_builder-4.8.1 lib/roku_builder/string.rb
roku_builder-4.8.0 lib/roku_builder/string.rb
roku_builder-4.7.2 lib/roku_builder/string.rb
roku_builder-4.7.1 lib/roku_builder/string.rb
roku_builder-4.7.0 lib/roku_builder/string.rb
roku_builder-4.6.2 lib/roku_builder/string.rb