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.30.0 lib/roku_builder/string.rb
roku_builder-4.29.9 lib/roku_builder/string.rb
roku_builder-4.29.8 lib/roku_builder/string.rb
roku_builder-4.29.7 lib/roku_builder/string.rb
roku_builder-4.29.6 lib/roku_builder/string.rb
roku_builder-4.29.4 lib/roku_builder/string.rb
roku_builder-4.29.2 lib/roku_builder/string.rb
roku_builder-4.29.1 lib/roku_builder/string.rb
roku_builder-4.28.0 lib/roku_builder/string.rb
roku_builder-4.27.2 lib/roku_builder/string.rb
roku_builder-4.27.1 lib/roku_builder/string.rb
roku_builder-4.27.0 lib/roku_builder/string.rb
roku_builder-4.26.2 lib/roku_builder/string.rb
roku_builder-4.26.1 lib/roku_builder/string.rb
roku_builder-4.26.0 lib/roku_builder/string.rb
roku_builder-4.25.6 lib/roku_builder/string.rb
roku_builder-4.25.5 lib/roku_builder/string.rb
roku_builder-4.25.4 lib/roku_builder/string.rb
roku_builder-4.25.3 lib/roku_builder/string.rb
roku_builder-4.25.1 lib/roku_builder/string.rb