Module: Smol::Coercion

Included in:
Command, Config
Defined in:
lib/smol/coercion.rb

Constant Summary collapse

TRUTHY_VALUES =
%w[true 1 yes].freeze

Instance Method Summary collapse

Instance Method Details

#coerce_value(raw, type) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/smol/coercion.rb', line 7

def coerce_value(raw, type)
  case type
  when :integer
    raw.to_i
  when :boolean
    TRUTHY_VALUES.include?(raw.to_s.downcase)
  else
    raw
  end
end