Sha256: f1aa96ab99b01d6088446f44f92241d7c17fd1522949ad569525e3e66cdf0b81
Contents?: true
Size: 879 Bytes
Versions: 1
Compression:
Stored size: 879 Bytes
Contents
module Animoto module Support module String # Transforms this string from underscore-form to camel case. Capitalizes # the first letter. # # @example # "this_is_a_underscored_string" # => "ThisIsAUnderscoredString" # # @return [String] the camel case form of this string def camelize self.gsub(/(?:^|_)(.)/) { $1.upcase } end # Transforms this string from camel case to underscore-form. Downcases the # entire string. # # @example # "ThisIsACamelCasedString" # => "this_is_a_camel_cased_string" # # @return [String] the underscored form of this string def underscore self.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase end end end end String.__send__ :include, Animoto::Support::String
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
animoto-1.0.0 | ./lib/animoto/support/string.rb |