Sha256: 14f39f5ca852424b6532e1376d09859099b2e4019e5a1cd40297d14814ea2a96

Contents?: true

Size: 522 Bytes

Versions: 3

Compression:

Stored size: 522 Bytes

Contents

module Suricate::Refinements
  module String
    refine ::String do
      def camelize
        self.dup.split(/_/).map{ |word| word.capitalize }.join('')
      end

      def constantize
        self.split('::').inject(Object) do |mod, class_name|
          mod.const_get(class_name)
        end
      end

      def underscore
        gsub(/(.)([A-Z])/,'\1_\2').downcase
      end

      def demodulize
        if i = rindex('::')
          [(i+2)..-1]
        else
          self
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
suricate-0.0.4 lib/suricate/refinements/string.rb
suricate-0.0.3 lib/suricate/refinements/string.rb
suricate-0.0.2 lib/suricate/refinements/string.rb