Module: LibUI::Utils

Defined in:
lib/libui/utils.rb

Class Method Summary collapse

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



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