Module: Casing::Camel::String

Defined in:
lib/casing/camel/string.rb

Class Method Summary collapse

Class Method Details

.call(val, include_values: nil, symbol_to_string: nil) ⇒ Object Also known as: !



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/casing/camel/string.rb', line 4

def self.call(val, include_values: nil, symbol_to_string: nil)
  include_values = include_values.nil? ? true : include_values
  symbol_to_string ||= false

  return val unless include_values
  return val if val.length == 0

  sym = val.is_a?(Symbol)

  val = val.to_s

  converted = val
    .chars.first.downcase +
      Pascal::String.(val)[1..-1]

  if !symbol_to_string && sym
    converted = converted.to_sym
  end

  converted
end