Class: Lutaml::Model::Type::Float

Inherits:
Value
  • Object
show all
Defined in:
lib/lutaml/model/type/float.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

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
# File 'lib/lutaml/model/type/float.rb', line 5

def self.cast(value, options = {})
  return nil if value.nil?

  Model::Services::Type::Validator::Number.validate!(value, options)
  value.to_f
end

.serialize(value) ⇒ Object



12
13
14
15
16
# File 'lib/lutaml/model/type/float.rb', line 12

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

  cast(value)
end

Instance Method Details

#to_json(*_args) ⇒ Object



28
29
30
# File 'lib/lutaml/model/type/float.rb', line 28

def to_json(*_args)
  value
end

#to_xmlObject

Instance methods for specific formats xs:float format



20
21
22
# File 'lib/lutaml/model/type/float.rb', line 20

def to_xml
  value.to_s
end

#to_yamlObject



24
25
26
# File 'lib/lutaml/model/type/float.rb', line 24

def to_yaml
  value
end