Sha256: d6f55232281ef981f44e9a39cc76e61f5db0451223af0e5cfd418b28ffb63ccf
Contents?: true
Size: 774 Bytes
Versions: 4
Compression:
Stored size: 774 Bytes
Contents
module Rasti module Types class Boolean class << self include Castable TRUE_FORMAT = /^t(rue)?$/i FALSE_FORMAT = /^f(alse)?$/i private def valid?(value) boolean?(value) || valid_string?(value) end def transform(value) boolean?(value) ? value : true_string?(value) end def boolean?(value) value == true || value == false end def valid_string?(value) value.is_a?(::String) && (true_string?(value) || false_string?(value)) end def true_string?(value) !!value.match(TRUE_FORMAT) end def false_string?(value) !!value.match(FALSE_FORMAT) end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rasti-types-1.1.2 | lib/rasti/types/boolean.rb |
rasti-types-1.1.1 | lib/rasti/types/boolean.rb |
rasti-types-1.1.0 | lib/rasti/types/boolean.rb |
rasti-types-1.0.0 | lib/rasti/types/boolean.rb |