Sha256: 181777f778795115e2ca6de8a87bff71b22b94458fa99d008fa0904758228364

Contents?: true

Size: 681 Bytes

Versions: 3

Compression:

Stored size: 681 Bytes

Contents

module Economic
  module Support
    module String
      def self.camel_back(name)
        name[0, 1].downcase + name[1..-1]
      end

      def self.demodulize(class_name_in_module)
        class_name_in_module.to_s.gsub(/^.*::/, "")
      end

      def self.underscore(camel_cased_word)
        word = camel_cased_word.to_s.dup
        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!
        word
      end

      def self.snakecase(word)
        # Use the method from Savon::CoreExt::String.snakecase
        word.snakecase
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rconomic-0.7.0 lib/economic/support/string.rb
rconomic-0.6.1 lib/economic/support/string.rb
rconomic-0.6.0 lib/economic/support/string.rb