Class: Lutaml::Model::Type::Boolean
- Inherits:
-
Value
- Object
- Value
- Lutaml::Model::Type::Boolean
show all
- Defined in:
- lib/lutaml/model/type/boolean.rb
Instance Attribute Summary
Attributes inherited from Value
#value
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Value
from_format, #initialize, #initialized?, register_format_to_from_methods, #to_s
Class Method Details
.cast(value, _options = {}) ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/lutaml/model/type/boolean.rb', line 5
def self.cast(value, _options = {})
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
|
.serialize(value) ⇒ Object
13
14
15
16
17
|
# File 'lib/lutaml/model/type/boolean.rb', line 13
def self.serialize(value)
return nil if value.nil?
cast(value)
end
|
Instance Method Details
#to_json(*_args) ⇒ Object
24
25
26
|
# File 'lib/lutaml/model/type/boolean.rb', line 24
def to_json(*_args)
value
end
|
#to_toml ⇒ Object
32
33
34
|
# File 'lib/lutaml/model/type/boolean.rb', line 32
def to_toml
value.to_s
end
|
#to_xml ⇒ Object
Format-specific serialization methods
20
21
22
|
# File 'lib/lutaml/model/type/boolean.rb', line 20
def to_xml
value.to_s
end
|
#to_yaml ⇒ Object
28
29
30
|
# File 'lib/lutaml/model/type/boolean.rb', line 28
def to_yaml
value
end
|