Sha256: ded043b7b514e3449787ad81bd6d39abd0d0115b28c85a3b8a284a48838d5526

Contents?: true

Size: 406 Bytes

Versions: 15

Compression:

Stored size: 406 Bytes

Contents

module SafeYAML
  class Transform
    class ToBoolean
      PREDEFINED_VALUES = {
        "yes"   => true,
        "on"    => true,
        "true"  => true,
        "no"    => false,
        "off"   => false,
        "false" => false
      }.freeze

      def transform?(value)
        key = value.downcase
        return PREDEFINED_VALUES.include?(key), PREDEFINED_VALUES[key]
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
safe_yaml-0.9.0 lib/safe_yaml/transform/to_boolean.rb
safe_yaml-0.8.6 lib/safe_yaml/transform/to_boolean.rb
safe_yaml-0.8.5 lib/safe_yaml/transform/to_boolean.rb
safe_yaml-0.8.4 lib/safe_yaml/transform/to_boolean.rb
safe_yaml-0.8.3 lib/safe_yaml/transform/to_boolean.rb
safe_yaml-0.8.2 lib/safe_yaml/transform/to_boolean.rb
safe_yaml-0.8.1 lib/safe_yaml/transform/to_boolean.rb
safe_yaml-0.8.0 lib/safe_yaml/transform/to_boolean.rb
safe_yaml-0.7.1 lib/safe_yaml/transform/to_boolean.rb
safe_yaml-0.7.0 lib/safe_yaml/transform/to_boolean.rb
safe_yaml-0.6.3 lib/safe_yaml/transform/to_boolean.rb
safe_yaml-0.6.2 lib/safe_yaml/transform/to_boolean.rb
safe_yaml-0.6.1 lib/safe_yaml/transform/to_boolean.rb
safe_yaml-0.5.2 lib/safe_yaml/transform/to_boolean.rb
safe_yaml-0.5.1 lib/safe_yaml/transform/to_boolean.rb