Sha256: 37ee2573ac18bb68d1fc0123420ffbd457c2108904374c4bd03ca1c1182f3d0b

Contents?: true

Size: 366 Bytes

Versions: 159

Compression:

Stored size: 366 Bytes

Contents

module Generator
  module Underscore
    refine String do
      def underscore
        downcase.gsub(/[- ]/, '_').gsub(/[^\w?]/, '')
      end

      def camel_case
        underscore.split('_').map(&:capitalize).join
      end
    end

    refine Integer do
      def underscore
        self.to_s.reverse.gsub(/...(?=.)/, '\&_').reverse
      end
    end
  end
end

Version data entries

159 entries across 159 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/ruby/lib/generator/underscore.rb
trackler-2.2.1.179 tracks/ruby/lib/generator/underscore.rb
trackler-2.2.1.178 tracks/ruby/lib/generator/underscore.rb
trackler-2.2.1.177 tracks/ruby/lib/generator/underscore.rb
trackler-2.2.1.176 tracks/ruby/lib/generator/underscore.rb
trackler-2.2.1.175 tracks/ruby/lib/generator/underscore.rb
trackler-2.2.1.174 tracks/ruby/lib/generator/underscore.rb
trackler-2.2.1.173 tracks/ruby/lib/generator/underscore.rb
trackler-2.2.1.172 tracks/ruby/lib/generator/underscore.rb
trackler-2.2.1.171 tracks/ruby/lib/generator/underscore.rb
trackler-2.2.1.170 tracks/ruby/lib/generator/underscore.rb
trackler-2.2.1.169 tracks/ruby/lib/generator/underscore.rb
trackler-2.2.1.167 tracks/ruby/lib/generator/underscore.rb
trackler-2.2.1.166 tracks/ruby/lib/generator/underscore.rb
trackler-2.2.1.165 tracks/ruby/lib/generator/underscore.rb
trackler-2.2.1.164 tracks/ruby/lib/generator/underscore.rb
trackler-2.2.1.163 tracks/ruby/lib/generator/underscore.rb
trackler-2.2.1.162 tracks/ruby/lib/generator/underscore.rb
trackler-2.2.1.161 tracks/ruby/lib/generator/underscore.rb
trackler-2.2.1.160 tracks/ruby/lib/generator/underscore.rb