Sha256: 59e52fbf986c8a7ad116b3952889b107f47799315ff6792212b58c2854375d07

Contents?: true

Size: 357 Bytes

Versions: 8

Compression:

Stored size: 357 Bytes

Contents

module Magent
  module Utils
    def self.underscore(word)
      word.to_s.gsub(/::/, '/').
                gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
                gsub(/([a-z\d])([A-Z])/,'\1_\2').tr("-", "_").downcase
    end

    def self.camelize(word)
      word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
magent-0.2 lib/magent/utils.rb
magent-0.1.3 lib/magent/utils.rb
magent-0.1.2 lib/magent/utils.rb
magent-0.1.1 lib/magent/utils.rb
magent-0.1.0 lib/magent/utils.rb
magent-0.0.3 lib/magent/utils.rb
magent-0.0.2 lib/magent/utils.rb
magent-0.0.1 lib/magent/utils.rb