Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/aspera/colors.rb
Overview
simple vt100 colors
Instance Method Summary collapse
-
#apply(*colors) ⇒ String
Applies the provided list of string decoration (colors).
-
#capital_to_snake ⇒ Object
Transform capitalized to snake case.
-
#snake_to_capital ⇒ Object
Transform snake case to capitalized.
Instance Method Details
#apply(*colors) ⇒ String
Applies the provided list of string decoration (colors).
64 65 66 |
# File 'lib/aspera/colors.rb', line 64 def apply(*colors) colors.reduce(self){ |s, c| s.public_send(c)} end |
#capital_to_snake ⇒ Object
Transform capitalized to snake case
69 70 71 72 73 |
# File 'lib/aspera/colors.rb', line 69 def capital_to_snake return gsub(/([a-z\d])([A-Z])/, '\1_\2') .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .downcase end |
#snake_to_capital ⇒ Object
Transform snake case to capitalized
76 77 78 |
# File 'lib/aspera/colors.rb', line 76 def snake_to_capital split('_').map(&:capitalize).join end |