class Aws::Lex::Conversation::Support::Inflector

Attributes

input[RW]

Public Class Methods

new(input) click to toggle source
# File lib/aws/lex/conversation/support/inflector.rb, line 10
def initialize(input)
  self.input = input.to_s
end

Public Instance Methods

to_camel_case(style = :lower) click to toggle source
# File lib/aws/lex/conversation/support/inflector.rb, line 25
def to_camel_case(style = :lower)
  parts = input.split('_')
  first = parts.shift
  rest = parts.map(&:capitalize)

  case style
  when :lower
    rest.unshift(first).join
  when :upper
    rest.unshift(first.capitalize).join
  else
    raise ArgumentError, "invalid option: `#{style.inspect}`"
  end
end
to_snake_case() click to toggle source
# File lib/aws/lex/conversation/support/inflector.rb, line 14
def to_snake_case
  # shamelessly borrowed from ActiveSupport
  input
    .gsub(/::/, '/')
    .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
    .gsub(/([a-z\d])([A-Z])/, '\1_\2')
    .tr('-', '_')
    .gsub(/\W/, '_')
    .downcase
end