Class: Lutaml::Model::Type::String
- Defined in:
- lib/lutaml/model/type/string.rb
Instance Attribute Summary
Attributes inherited from Value
Class Method Summary collapse
- .cast(value, options = {}) ⇒ Object
- .from_json(value) ⇒ Object
- .from_toml(value) ⇒ Object
- .from_xml(value) ⇒ Object
- .from_yaml(value) ⇒ Object
Instance Method Summary collapse
-
#to_json(*_args) ⇒ Object
JSON string.
-
#to_toml ⇒ Object
TOML string.
-
#to_xml ⇒ Object
xs:string format.
-
#to_yaml ⇒ Object
YAML string.
Methods inherited from Value
from_format, #initialize, #initialized?, register_format_to_from_methods, serialize, #to_s
Constructor Details
This class inherits a constructor from Lutaml::Model::Type::Value
Class Method Details
.cast(value, options = {}) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/lutaml/model/type/string.rb', line 5 def self.cast(value, = {}) return nil if value.nil? value = value.to_s Model::Services::Type::Validator::String.validate!(value, ) value end |
.from_json(value) ⇒ Object
37 38 39 |
# File 'lib/lutaml/model/type/string.rb', line 37 def self.from_json(value) cast(value) end |
.from_toml(value) ⇒ Object
45 46 47 |
# File 'lib/lutaml/model/type/string.rb', line 45 def self.from_toml(value) cast(value) end |
.from_xml(value) ⇒ Object
33 34 35 |
# File 'lib/lutaml/model/type/string.rb', line 33 def self.from_xml(value) cast(value) end |
.from_yaml(value) ⇒ Object
41 42 43 |
# File 'lib/lutaml/model/type/string.rb', line 41 def self.from_yaml(value) cast(value) end |
Instance Method Details
#to_json(*_args) ⇒ Object
JSON string
19 20 21 |
# File 'lib/lutaml/model/type/string.rb', line 19 def to_json(*_args) value end |
#to_toml ⇒ Object
TOML string
29 30 31 |
# File 'lib/lutaml/model/type/string.rb', line 29 def to_toml value&.to_s end |
#to_xml ⇒ Object
xs:string format
14 15 16 |
# File 'lib/lutaml/model/type/string.rb', line 14 def to_xml value&.to_s end |
#to_yaml ⇒ Object
YAML string
24 25 26 |
# File 'lib/lutaml/model/type/string.rb', line 24 def to_yaml value end |