Sha256: 61d10fe44f2def81e8ef7f6e811ea104cff8db32a479d70a6724b70a1fdbc59d

Contents?: true

Size: 357 Bytes

Versions: 13

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

13 entries across 13 versions & 2 rubygems

Version Path
magent-0.7.0 lib/magent/utils.rb
magent-0.6.2 lib/magent/utils.rb
magent-0.6.1 lib/magent/utils.rb
magent-0.6.0 lib/magent/utils.rb
magent-0.5.4 lib/magent/utils.rb
magent-0.5.3 lib/magent/utils.rb
magent-0.5.2 lib/magent/utils.rb
magent-0.5.1 lib/magent/utils.rb
magent-0.5.0 lib/magent/utils.rb
magent-0.4.2 lib/magent/utils.rb
thirtysixthspan-magent-0.4.1 lib/magent/utils.rb
magent-0.4 lib/magent/utils.rb
magent-0.3 lib/magent/utils.rb