Class: Lutaml::Model::Type::String

Inherits:
Value
  • Object
show all
Defined in:
lib/lutaml/model/type/string.rb

Instance Attribute Summary

Attributes inherited from Value

#value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Value

from_format, #initialize, serialize, #to_s

Constructor Details

This class inherits a constructor from Lutaml::Model::Type::Value

Class Method Details

.cast(value) ⇒ Object



5
6
7
8
9
# File 'lib/lutaml/model/type/string.rb', line 5

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

  value.to_s
end

.from_json(value) ⇒ Object



35
36
37
# File 'lib/lutaml/model/type/string.rb', line 35

def self.from_json(value)
  cast(value)
end

.from_toml(value) ⇒ Object



43
44
45
# File 'lib/lutaml/model/type/string.rb', line 43

def self.from_toml(value)
  cast(value)
end

.from_xml(value) ⇒ Object



31
32
33
# File 'lib/lutaml/model/type/string.rb', line 31

def self.from_xml(value)
  cast(value)
end

.from_yaml(value) ⇒ Object



39
40
41
# File 'lib/lutaml/model/type/string.rb', line 39

def self.from_yaml(value)
  cast(value)
end

Instance Method Details

#to_json(*_args) ⇒ Object

JSON string



17
18
19
# File 'lib/lutaml/model/type/string.rb', line 17

def to_json(*_args)
  value
end

#to_tomlObject

TOML string



27
28
29
# File 'lib/lutaml/model/type/string.rb', line 27

def to_toml
  value&.to_s
end

#to_xmlObject

xs:string format



12
13
14
# File 'lib/lutaml/model/type/string.rb', line 12

def to_xml
  value&.to_s
end

#to_yamlObject

YAML string



22
23
24
# File 'lib/lutaml/model/type/string.rb', line 22

def to_yaml
  value
end