Class Amalgalite::Boolean
In: lib/amalgalite/boolean.rb
Parent: Object

Do type conversion on values that could be boolen values into real ‘true’ or ‘false‘

This is pulled from the possible boolean values from PostgreSQL

Methods

Public Class methods

list of downcased strings are potential false values

[Source]

    # File lib/amalgalite/boolean.rb, line 24
24:       def false_values
25:         @false_values ||= %w[ false f no n 0 ]
26:       end

Convert val to a string and attempt to convert it to true or false

[Source]

    # File lib/amalgalite/boolean.rb, line 31
31:       def to_bool( val )
32:         return false if val.nil?
33:         unless @to_bool
34:           @to_bool = {}
35:           true_values.each  { |t| @to_bool[t] = true  }
36:           false_values.each { |f| @to_bool[f] = false }
37:         end
38:         return @to_bool[val.to_s.downcase]
39:       end

list of downcased strings are potential true values

[Source]

    # File lib/amalgalite/boolean.rb, line 17
17:       def true_values
18:         @true_values ||= %w[ true t yes y 1 ]
19:       end

[Validate]