Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/modular_state_machine.rb
Overview
End ModularStateMachine
Instance Method Summary collapse
- #demodulize ⇒ Object
- #pluralize ⇒ Object
- #singularize ⇒ Object
- #tableize ⇒ Object
- #underscore ⇒ Object
Instance Method Details
#demodulize ⇒ Object
78 79 80 |
# File 'lib/modular_state_machine.rb', line 78 def demodulize self.split('::').last end |
#pluralize ⇒ Object
90 91 92 |
# File 'lib/modular_state_machine.rb', line 90 def pluralize self + 's' end |
#singularize ⇒ Object
98 99 100 |
# File 'lib/modular_state_machine.rb', line 98 def singularize self.end_with?('s') ? self[0...-1] : self end |
#tableize ⇒ Object
94 95 96 |
# File 'lib/modular_state_machine.rb', line 94 def tableize underscore.pluralize end |
#underscore ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/modular_state_machine.rb', line 82 def underscore gsub(/::/, '/') .gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2') .gsub(/([a-z\d])([A-Z])/,'\1_\2') .tr("-", "_") .downcase end |