Parent

Class/Module Index [+]

Quicksearch

Amalgalite::Boolean

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

Public Class Methods

false_values() click to toggle source

list of downcased strings are potential false values

# File lib/amalgalite/boolean.rb, line 24
def false_values
  @false_values ||= ] false f no n 0 ]
end
to_bool( val ) click to toggle source

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

# File lib/amalgalite/boolean.rb, line 31
def to_bool( val )
  return false if val.nil?
  unless defined? @to_bool
    @to_bool = {}
    true_values.each  { |t| @to_bool[t] = true  }
    false_values.each { |f| @to_bool[f] = false }
  end
  return @to_bool[val.to_s.downcase]
end
true_values() click to toggle source

list of downcased strings are potential true values

# File lib/amalgalite/boolean.rb, line 17
def true_values
  @true_values ||= ] true t yes y 1 ]
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.