Sha256: 129a8bc3397fc681b9406ef0d6ed8669df01e83e321a4d9eed6b0637fc138a0b

Contents?: true

Size: 494 Bytes

Versions: 2

Compression:

Stored size: 494 Bytes

Contents

class String
  # Replaces spaces and tabs with _ so we can use the string as a method name
  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

2 entries across 2 versions & 1 rubygems

Version Path
jeremymcanally-context-0.0.5 lib/context/core_ext/string.rb
jeremymcanally-context-0.0.6 lib/context/core_ext/string.rb