Sha256: 6d2e70fc817aef1e3b9913a125a16a43a6c5c7e51230228b1c7666569e61110b
Contents?: true
Size: 1.18 KB
Versions: 30
Compression:
Stored size: 1.18 KB
Contents
module Stove module Util extend self # Convert a version string (x.y.z) to a community-site friendly format # (x_y_z). # # @example Convert a version to a version string # format_version('1.2.3') #=> 1_2_3 # # @param [#to_s] version # the version string to convert # # @return [String] def version_for_url(version) version .to_s .gsub('.', '_') end # # Covert the given CaMelCaSeD string to under_score. Graciously borrowed # from http://stackoverflow.com/questions/1509915. # # @param [String] string # the string to use for transformation # # @return [String] # def underscore(string) string .to_s .gsub(/::/, '/') .gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2') .gsub(/([a-z\d])([A-Z])/,'\1_\2') .tr('-', '_') .downcase end # # Convert an underscored string to it's camelcase equivalent constant. # # @param [String] # the string to convert # # @return [String] # def camelize(string) string .to_s .split('_') .map { |e| e.capitalize } .join end end end
Version data entries
30 entries across 30 versions & 3 rubygems