Module: LibUI::Utils
- Defined in:
- lib/libui/utils.rb
Class Method Summary collapse
- .convert_to_ruby_method(original_method_name) ⇒ Object
-
.underscore(str) ⇒ Object
Converting camel case to underscore case in ruby stackoverflow.com/questions/1509915/converting-camel-case-to-underscore-case-in-ruby#1509939.
Class Method Details
.convert_to_ruby_method(original_method_name) ⇒ Object
4 5 6 |
# File 'lib/libui/utils.rb', line 4 def convert_to_ruby_method(original_method_name) underscore(original_method_name.delete_prefix('ui')) end |
.underscore(str) ⇒ Object
Converting camel case to underscore case in ruby stackoverflow.com/questions/1509915/converting-camel-case-to-underscore-case-in-ruby#1509939
10 11 12 13 14 15 16 |
# File 'lib/libui/utils.rb', line 10 def underscore(str) str.gsub(/::/, '/') # Maybe we don't need it. .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr('-', '_') .downcase end |