Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/core_ext.rb
Instance Method Summary collapse
Instance Method Details
#match?(*args) ⇒ Boolean
21 22 23 |
# File 'lib/core_ext.rb', line 21 def match?(*args) !!match(*args) end |
#symbolize ⇒ Object
25 26 27 |
# File 'lib/core_ext.rb', line 25 def symbolize underscore.to_sym end |
#underscore ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/core_ext.rb', line 12 def underscore return self unless /[A-Z-]|::/.match?(self) to_s.gsub('::', '/') .gsub(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr('- ', '_') .downcase end |