Sha256: bd7753f45732444f54b2a169ce35d01c9b43437950e6a5b35bf4ebf2fcb38435
Contents?: true
Size: 948 Bytes
Versions: 1
Compression:
Stored size: 948 Bytes
Contents
module CodeKindly module Utils class Boolean # modified from ActiveRecord::ConnectionAdapters::Column (4.2.9) TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE', 'on', 'ON', 'y', 'yes'] FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE', 'off', 'OFF', 'n', 'no'] class << self def from (value) return true if is_true?(value) return false if is_false?(value) nil end def is_false? (value) return true if FALSE_VALUES.include?(value) if value.respond_to?(:downcase) return true if FALSE_VALUES.include?(value.downcase) end false end def is_true? (value) return true if TRUE_VALUES.include?(value) if value.respond_to?(:downcase) return true if TRUE_VALUES.include?(value.downcase) end false end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
codekindly-utils-0.0.1 | lib/code_kindly/utils/boolean.rb |