Class: Coppy::Name

Inherits:
Object
  • Object
show all
Defined in:
lib/coppy/name.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#underscoreObject (readonly)

Returns the value of attribute underscore.



12
13
14
# File 'lib/coppy/name.rb', line 12

def underscore
  @underscore
end

Instance Method Details

#camelcaseObject



14
15
16
# File 'lib/coppy/name.rb', line 14

def camelcase
  @underscore.split('_').map(&:capitalize).join
end