Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/cfnvpn/string.rb

Instance Method Summary collapse

Instance Method Details

#colorize(color_code) ⇒ Object



18
19
20
# File 'lib/cfnvpn/string.rb', line 18

def colorize(color_code)
  "\e[#{color_code}m#{self}\e[0m"
end

#event_id_safeObject



14
15
16
# File 'lib/cfnvpn/string.rb', line 14

def event_id_safe
  self.gsub('*', 'wildcard').gsub(/[^\.\-_A-Za-z0-9]+/, "").downcase
end

#greenObject



26
27
28
# File 'lib/cfnvpn/string.rb', line 26

def green
  colorize(32)
end

#redObject



22
23
24
# File 'lib/cfnvpn/string.rb', line 22

def red
  colorize(31)
end

#resource_safeObject



10
11
12
# File 'lib/cfnvpn/string.rb', line 10

def resource_safe
  self.gsub(/[^a-zA-Z0-9]/, "").capitalize
end

#underscoreObject



2
3
4
5
6
7
8
# File 'lib/cfnvpn/string.rb', line 2

def underscore
  self.gsub(/::/, '/').
  gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
  gsub(/([a-z\d])([A-Z])/,'\1_\2').
  tr("-", "_").
  downcase
end

#yellowObject



30
31
32
# File 'lib/cfnvpn/string.rb', line 30

def yellow
  colorize(33)
end