Module: BothIsGood::Context::Names

Included in:
Error, Result, Switching
Defined in:
lib/both_is_good/context/names.rb

Instance Method Summary collapse

Instance Method Details

#class_to_tag(klass) ⇒ Object



12
# File 'lib/both_is_good/context/names.rb', line 12

def class_to_tag(klass) = underscore(klass.name)

#method_to_tag(klass, method_name) ⇒ Object



14
# File 'lib/both_is_good/context/names.rb', line 14

def method_to_tag(klass, method_name) = "#{class_to_tag(klass)}--#{method_name}"

#underscore(supplied_name) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/both_is_good/context/names.rb', line 4

def underscore(supplied_name)
  supplied_name
    .gsub("::", "/")
    .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
    .gsub(/([a-z\d])([A-Z])/, '\1_\2')
    .downcase
end