class RDF::Literal::Base64Binary
base64Binary represents Base64-encoded arbitrary binary data. The ·value space· of base64Binary is the set of finite-length sequences of binary octets. For base64Binary data the entire binary stream is encoded using the Base64 Alphabet in [RFC 2045].
Constants
- DATATYPE
Public Class Methods
new(value, datatype: nil, lexical: nil, **options)
click to toggle source
@param [String, Object] value
If given a string, it will decode it as an object value. Otherwise, it will take the value as the object and encode to retrieve a value
@option options [String] :lexical (nil)
Calls superclass method
# File lib/rdf/xsd/binary.rb, line 69 def initialize(value, datatype: nil, lexical: nil, **options) super(value, datatype: datatype, lexical: lexical) @object = value.is_a?(String) ? ::Base64.decode64(value) : value canonicalize! unless value.is_a?(String) end
Public Instance Methods
canonicalize!()
click to toggle source
Converts this literal into its canonical lexical representation.
@return [RDF::Literal] ‘self` @see www.w3.org/TR/xmlschema-2/#dateTime
# File lib/rdf/xsd/binary.rb, line 88 def canonicalize! @string = ::Base64.encode64(@object) self end
to_s()
click to toggle source
Returns the value as a string.
@return [String]
# File lib/rdf/xsd/binary.rb, line 79 def to_s @string || @object.to_s end
valid?()
click to toggle source
Returns ‘true` if the value adheres to the defined grammar of the datatype.
@return [Boolean]
# File lib/rdf/xsd/binary.rb, line 98 def valid? !!Base64.strict_decode64(value.gsub(/\s+/m, '')) rescue ArgumentError false end