Class: Coppy::Name
- Inherits:
-
Object
- Object
- Coppy::Name
- Defined in:
- lib/coppy/name.rb
Instance Attribute Summary collapse
-
#underscore ⇒ Object
readonly
Returns the value of attribute underscore.
Instance Method Summary collapse
- #camelcase ⇒ Object
-
#initialize(name) ⇒ Name
constructor
A new instance of Name.
Constructor Details
#initialize(name) ⇒ Name
Returns a new instance of Name.
3 4 5 6 7 8 9 10 |
# File 'lib/coppy/name.rb', line 3 def initialize(name) @underscore = name .gsub(/::/, '/') .gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2') .gsub(/([a-z\d])([A-Z])/,'\1_\2') .tr("-", "_") .downcase end |
Instance Attribute Details
#underscore ⇒ Object (readonly)
Returns the value of attribute underscore.
12 13 14 |
# File 'lib/coppy/name.rb', line 12 def underscore @underscore end |
Instance Method Details
#camelcase ⇒ Object
14 15 16 |
# File 'lib/coppy/name.rb', line 14 def camelcase @underscore.split('_').map(&:capitalize).join end |