Class: Lutaml::Model::Type::Boolean
- Defined in:
- lib/lutaml/model/type/boolean.rb
Constant Summary
Constants inherited from Value
Instance Attribute Summary
Attributes inherited from Value
Class Method Summary collapse
- .cast(value, _options = {}) ⇒ Object
-
.default_xsd_type ⇒ String
Default XSD type for Boolean.
- .serialize(value) ⇒ Object
Methods inherited from Value
format_type_serializer_for, from_format, #initialize, #initialized?, register_format_to_from_methods, register_format_type_serializer, #to_s
Methods included from Xml::Type::Configurable
Methods included from UninitializedClassGuard
Constructor Details
This class inherits a constructor from Lutaml::Model::Type::Value
Class Method Details
.cast(value, _options = {}) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/lutaml/model/type/boolean.rb', line 7 def self.cast(value, = {}) return nil if value.nil? return value if Utils.uninitialized?(value) 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 |
.default_xsd_type ⇒ String
Default XSD type for Boolean
25 26 27 |
# File 'lib/lutaml/model/type/boolean.rb', line 25 def self.default_xsd_type "xs:boolean" end |
.serialize(value) ⇒ Object
16 17 18 19 20 |
# File 'lib/lutaml/model/type/boolean.rb', line 16 def self.serialize(value) return nil if value.nil? !!value end |