Module: Context::String
- Included in:
- String
- Defined in:
- lib/context/core_ext/string.rb
Instance Method Summary collapse
-
#to_class_name ⇒ Object
Borrowed from
camelize
in ActiveSupport. -
#to_method_name ⇒ Object
Replaces spaces and tabs with _ so we can use the string as a method name Also replace dangerous punctuation.
-
#to_module_name ⇒ Object
Borrowed from
camelize
in ActiveSupport.
Instance Method Details
#to_class_name ⇒ Object
Borrowed from camelize
in ActiveSupport
19 20 21 22 23 24 |
# File 'lib/context/core_ext/string.rb', line 19 def to_class_name meth_name = self.to_method_name meth_name.gsub!(/\/(.?)/) { "#{$1.upcase}" } meth_name.gsub!(/(?:^|_)(.)/) { $1.upcase } meth_name end |
#to_method_name ⇒ Object
Replaces spaces and tabs with _ so we can use the string as a method name Also replace dangerous punctuation
4 5 6 7 8 |
# File 'lib/context/core_ext/string.rb', line 4 def to_method_name downcased = self.downcase downcased.gsub!(/[\s:',\.~;!#=\-\(\)\?]+/,'_') downcased end |
#to_module_name ⇒ Object
Borrowed from camelize
in ActiveSupport
11 12 13 14 15 16 |
# File 'lib/context/core_ext/string.rb', line 11 def to_module_name meth_name = self.to_method_name meth_name.gsub!(/\/(.?)/) { "::#{$1.upcase}" } meth_name.gsub!(/(?:^|_)(.)/) { $1.upcase } meth_name end |