class String

Public Instance Methods

to_camelcase() click to toggle source
# File lib/cfnguardian/string.rb, line 12
def to_camelcase
  self.split('_').collect(&:capitalize).join
end
to_heading() click to toggle source
# File lib/cfnguardian/string.rb, line 22
def to_heading
  self.split('_').collect(&:capitalize).join(' ')
end
to_resource_name() click to toggle source
# File lib/cfnguardian/string.rb, line 16
def to_resource_name
  self.split(/(\.|-|_)/).
  map(&:capitalize).join.
  gsub(/[^0-9A-Za-z]/, '')
end
to_underscore() click to toggle source
# File lib/cfnguardian/string.rb, line 4
def to_underscore
  self.gsub(/::/, '/').
  gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
  gsub(/([a-z\d])([A-Z])/,'\1_\2').
  tr("-", "_").
  downcase
end
word_wrap(with=100) click to toggle source
# File lib/cfnguardian/string.rb, line 26
def word_wrap(with=100)
  self.scan(/\S.{0,#{with}}\S(?=\s|$)|\S+/).
  map {|line| line + "\n"}.
  join('')
end