Module: Seahorse::ApiTranslator::Inflector

Included in:
Operation, Shape
Defined in:
lib/seahorse/api_translator/inflector.rb

Instance Method Summary collapse

Instance Method Details

#inflect(string, format = nil) ⇒ String

Performs a very simple inflection on on the words as they are formatted in the source API configurations. These are not general case inflectors.

Parameters:

  • string (String)

    The string to inflect.

  • format (String, nil) (defaults to: nil)

    Valid formats include ‘snake_case’, ‘camelCase’ and ‘nil` (leave as is).

Returns:

  • (String)


27
28
29
30
31
32
33
# File 'lib/seahorse/api_translator/inflector.rb', line 27

def inflect string, format = nil
  case format
  when 'camelCase' then string.camelize
  when 'snake_case' then string.underscore
  else string
  end
end