Sha256: 3cf92a89c3fc6dab1b36e712f73a81e6b7662b325bf740514c1171dc3b0e21af
Contents?: true
Size: 782 Bytes
Versions: 2
Compression:
Stored size: 782 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).nil? end def false_string?(value) !value.match(FALSE_FORMAT).nil? end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rasti-types-2.0.1 | lib/rasti/types/boolean.rb |
rasti-types-2.0.0 | lib/rasti/types/boolean.rb |