Class: Langchain::Utils::ToBoolean

Inherits:
Object
  • Object
show all
Defined in:
lib/langchain/utils/to_boolean.rb

Instance Method Summary collapse

Instance Method Details

#to_bool(value) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/langchain/utils/to_boolean.rb', line 9

def to_bool(value)
  case value
  when String
    TRUTHABLE_STRINGS.include?(value.downcase)
  when Integer
    value == 1
  when TrueClass
    true
  when FalseClass
    false
  when Symbol
    to_bool(value.to_s)
  else
    false
  end
end