Sha256: 8b76584643ed249a6bde2d669798e7ee513091b79d6f13440add43a6ac3f67ee
Contents?: true
Size: 547 Bytes
Versions: 29
Compression:
Stored size: 547 Bytes
Contents
class String # Replaces spaces and tabs with _ so we can use the string as a method name # Also replace dangerous punctuation def to_method_name self.downcase.gsub(/[\s:',\.~;!#=\(\)&]+/,'_') end # Borrowed from +camelize+ in ActiveSupport def to_module_name self.to_method_name.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } end # Borrowed from +camelize+ in ActiveSupport def to_class_name self.to_method_name.gsub(/\/(.?)/) { "#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } end end
Version data entries
29 entries across 29 versions & 4 rubygems