Sha256: 2495c467598ebc3cd3aa783c76325e610ec24629d1f9ee800e27cc6c980e6e70

Contents?: true

Size: 770 Bytes

Versions: 21

Compression:

Stored size: 770 Bytes

Contents

module Lutaml
  module Model
    module Type
      class Boolean < Value
        def self.cast(value)
          return nil if value.nil?
          return true if value == true || value.to_s.match?(/^(true|t|yes|y|1)$/i)
          return false if value == false || value.to_s.match?(/^(false|f|no|n|0)$/i)

          value
        end

        def self.serialize(value)
          return nil if value.nil?

          cast(value) # Return actual boolean instead of string
        end

        # Format-specific serialization methods
        def to_xml
          value.to_s
        end

        def to_json(*_args)
          value
        end

        def to_yaml
          value
        end

        def to_toml
          value.to_s
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
lutaml-model-0.7.0 lib/lutaml/model/type/boolean.rb
lutaml-model-0.6.7 lib/lutaml/model/type/boolean.rb
lutaml-model-0.6.6 lib/lutaml/model/type/boolean.rb
lutaml-model-0.6.5 lib/lutaml/model/type/boolean.rb
lutaml-model-0.6.4 lib/lutaml/model/type/boolean.rb
lutaml-model-0.6.3 lib/lutaml/model/type/boolean.rb
lutaml-model-0.6.2 lib/lutaml/model/type/boolean.rb
lutaml-model-0.6.1 lib/lutaml/model/type/boolean.rb
lutaml-model-0.6.0 lib/lutaml/model/type/boolean.rb
lutaml-model-0.5.4 lib/lutaml/model/type/boolean.rb
lutaml-model-0.5.3 lib/lutaml/model/type/boolean.rb
lutaml-model-0.5.2 lib/lutaml/model/type/boolean.rb
lutaml-model-0.5.1 lib/lutaml/model/type/boolean.rb
lutaml-model-0.5.0 lib/lutaml/model/type/boolean.rb
lutaml-model-0.4.0 lib/lutaml/model/type/boolean.rb
lutaml-model-0.3.30 lib/lutaml/model/type/boolean.rb
lutaml-model-0.3.29 lib/lutaml/model/type/boolean.rb
lutaml-model-0.3.28 lib/lutaml/model/type/boolean.rb
lutaml-model-0.3.27 lib/lutaml/model/type/boolean.rb
lutaml-model-0.3.26 lib/lutaml/model/type/boolean.rb