Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/awsutils/ec2info.rb
Instance Method Summary collapse
Instance Method Details
#title_case ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/awsutils/ec2info.rb', line 14 def title_case underscore.split('_').map do |word| # Recognize certain special cases (e.g. acronyms) if %w[iam ebs id dns vpc].include? word.downcase word.upcase elsif word.casecmp('ids').zero? 'IDs' else word.capitalize end end.join(' ') end |
#underscore ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/awsutils/ec2info.rb', line 6 def underscore gsub(/::/, '/') .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr('-', '_') .downcase end |