Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/tu-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
14 15 16 |
# File 'lib/tu-context/core_ext/string.rb', line 14 def to_class_name self.to_method_name.gsub(/\/(.?)/) { "#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } 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 |
# File 'lib/tu-context/core_ext/string.rb', line 4 def to_method_name self.downcase.gsub(/[\s:',\.~;!#=\(\)&\?]+/, '_') end |
#to_module_name ⇒ Object
Borrowed from camelize
in ActiveSupport
9 10 11 |
# File 'lib/tu-context/core_ext/string.rb', line 9 def to_module_name self.to_method_name.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } end |