Class: Lutaml::Model::Type::Base64Binary
- Defined in:
- lib/lutaml/model/type/base64_binary.rb
Overview
Base64Binary type for xs:base64Binary
Handles base64 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 base64 to binary data.
-
.default_xsd_type ⇒ String
XSD type for Base64Binary.
-
.encode(data) ⇒ String
Encode binary data to base64.
- .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
15 16 17 18 19 20 21 |
# File 'lib/lutaml/model/type/base64_binary.rb', line 15 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 base64 to binary data
50 51 52 53 54 |
# File 'lib/lutaml/model/type/base64_binary.rb', line 50 def self.decode(encoded) return nil if encoded.nil? Base64.strict_decode64(encoded) end |
.default_xsd_type ⇒ String
XSD type for Base64Binary
32 33 34 |
# File 'lib/lutaml/model/type/base64_binary.rb', line 32 def self.default_xsd_type "xs:base64Binary" end |
.encode(data) ⇒ String
Encode binary data to base64
40 41 42 43 44 |
# File 'lib/lutaml/model/type/base64_binary.rb', line 40 def self.encode(data) return nil if data.nil? Base64.strict_encode64(data) end |
.serialize(value) ⇒ Object
23 24 25 26 27 |
# File 'lib/lutaml/model/type/base64_binary.rb', line 23 def self.serialize(value) return nil if value.nil? value.to_s end |