Class: Lutaml::Model::Type::HexBinary
- Defined in:
- lib/lutaml/model/type/hex_binary.rb
Overview
HexBinary type for xs:hexBinary
Handles hexadecimal encoding/decoding of binary data
Constant Summary
Constants inherited from Value
Instance Attribute Summary
Attributes inherited from Value
Class Method Summary collapse
- .cast(value, _options = {}) ⇒ Object
-
.decode(encoded) ⇒ String
Decode hex to binary data.
-
.default_xsd_type ⇒ String
XSD type for HexBinary.
-
.encode(data) ⇒ String
Encode binary data to hex.
- .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
13 14 15 16 17 18 19 |
# File 'lib/lutaml/model/type/hex_binary.rb', line 13 def self.cast(value, = {}) return nil if value.nil? return value if Utils.uninitialized?(value) return value if value.is_a?(::String) value.to_s end |
.decode(encoded) ⇒ String
Decode hex to binary data
48 49 50 51 52 |
# File 'lib/lutaml/model/type/hex_binary.rb', line 48 def self.decode(encoded) return nil if encoded.nil? [encoded].pack("H*") end |
.default_xsd_type ⇒ String
XSD type for HexBinary
30 31 32 |
# File 'lib/lutaml/model/type/hex_binary.rb', line 30 def self.default_xsd_type "xs:hexBinary" end |
.encode(data) ⇒ String
Encode binary data to hex
38 39 40 41 42 |
# File 'lib/lutaml/model/type/hex_binary.rb', line 38 def self.encode(data) return nil if data.nil? data.unpack1("H*") end |
.serialize(value) ⇒ Object
21 22 23 24 25 |
# File 'lib/lutaml/model/type/hex_binary.rb', line 21 def self.serialize(value) return nil if value.nil? value.to_s end |