Module: TTY::Option::Inflection
- Included in:
- DSL, ErrorAggregator
- Defined in:
- lib/tty/option/inflection.rb
Class Method Summary collapse
-
.dasherize(name) ⇒ Object
Convert class name to dashed case.
-
.demodulize(name) ⇒ String
Remove all modules/class names.
-
.underscore(name) ⇒ String
Convert class name to underscore.
Class Method Details
.dasherize(name) ⇒ Object
Convert class name to dashed case
44 45 46 |
# File 'lib/tty/option/inflection.rb', line 44 def dasherize(name) underscore(name).tr("_", "-") end |
.demodulize(name) ⇒ String
Remove all modules/class names
15 16 17 |
# File 'lib/tty/option/inflection.rb', line 15 def demodulize(name) name.to_s.split("::").last end |
.underscore(name) ⇒ String
Convert class name to underscore
29 30 31 32 33 34 |
# File 'lib/tty/option/inflection.rb', line 29 def underscore(name) name.to_s .gsub(/([A-Z\d]+)([A-Z][a-z])/, "\\1_\\2") .gsub(/([a-z\d]+)([A-Z])/, "\\1_\\2") .downcase end |