Class: Chemtrail::ClassNameInflector
- Inherits:
-
Object
- Object
- Chemtrail::ClassNameInflector
- Defined in:
- lib/chemtrail/class_name_inflector.rb
Instance Attribute Summary collapse
-
#class_name ⇒ Object
readonly
Returns the value of attribute class_name.
Instance Method Summary collapse
-
#initialize(class_name) ⇒ ClassNameInflector
constructor
A new instance of ClassNameInflector.
- #underscore ⇒ Object
Constructor Details
#initialize(class_name) ⇒ ClassNameInflector
Returns a new instance of ClassNameInflector.
4 5 6 |
# File 'lib/chemtrail/class_name_inflector.rb', line 4 def initialize(class_name) @class_name = class_name.to_s.dup end |
Instance Attribute Details
#class_name ⇒ Object (readonly)
Returns the value of attribute class_name.
2 3 4 |
# File 'lib/chemtrail/class_name_inflector.rb', line 2 def class_name @class_name end |
Instance Method Details
#underscore ⇒ Object
8 9 10 11 12 13 |
# File 'lib/chemtrail/class_name_inflector.rb', line 8 def underscore class_name.gsub(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2') .gsub(/([a-z\d])([A-Z])/,'\1_\2') .gsub(/::/,':') .downcase end |