Class: Flor::Pro::Strings::StringWrapper
- Inherits:
-
Object
- Object
- Flor::Pro::Strings::StringWrapper
- Extended by:
- Forwardable
- Defined in:
- lib/flor/pcore/strings.rb
Instance Method Summary collapse
- #camelcase ⇒ Object
- #capitalize ⇒ Object
-
#initialize(s) ⇒ StringWrapper
constructor
A new instance of StringWrapper.
- #snakecase ⇒ Object
Constructor Details
#initialize(s) ⇒ StringWrapper
Returns a new instance of StringWrapper.
102 |
# File 'lib/flor/pcore/strings.rb', line 102 def initialize(s); @s = s; end |
Instance Method Details
#camelcase ⇒ Object
104 105 106 107 108 |
# File 'lib/flor/pcore/strings.rb', line 104 def camelcase @s .gsub(/_(.)/) { |_| $1.upcase } end |
#capitalize ⇒ Object
110 111 112 113 114 |
# File 'lib/flor/pcore/strings.rb', line 110 def capitalize @s .gsub(/\b[a-z]/) { |c| c.upcase } end |
#snakecase ⇒ Object
116 117 118 119 120 121 |
# File 'lib/flor/pcore/strings.rb', line 116 def snakecase @s .gsub(/([a-z])([A-Z])/) { |_| $1 + '_' + $2.downcase } .gsub(/([A-Z])/) { |c| c.downcase } end |