Class: RDF::Literal::HexBinary
- Inherits:
-
RDF::Literal
- Object
- RDF::Literal
- RDF::Literal::HexBinary
- Defined in:
- lib/rdf/xsd/binary.rb
Overview
hexBinary represents arbitrary hex-encoded binary data. The value space of hexBinary is the set of finite-length sequences of binary octets.
Constant Summary collapse
- DATATYPE =
RDF::XSD.hexBinary
- GRAMMAR =
%r(\A[0-9a-fA-F]+\Z)
Instance Method Summary collapse
-
#canonicalize! ⇒ RDF::Literal
Converts this literal into its canonical lexical representation.
-
#initialize(value, datatype: nil, lexical: nil, **options) ⇒ HexBinary
constructor
A new instance of HexBinary.
-
#to_s ⇒ String
Returns the encoded value as a string.
Constructor Details
#initialize(value, datatype: nil, lexical: nil, **options) ⇒ HexBinary
Returns a new instance of HexBinary.
22 23 24 25 26 |
# File 'lib/rdf/xsd/binary.rb', line 22 def initialize(value, datatype: nil, lexical: nil, **) super(value, datatype: datatype, lexical: lexical) @object = .fetch(:object, hex_to_bin(value.to_s)) @string ||= bin_to_hex(@object) end |
Instance Method Details
#canonicalize! ⇒ RDF::Literal
Converts this literal into its canonical lexical representation.
32 33 34 35 |
# File 'lib/rdf/xsd/binary.rb', line 32 def canonicalize! @string = bin_to_hex(@object) self end |
#to_s ⇒ String
Returns the encoded value as a string.
41 42 43 |
# File 'lib/rdf/xsd/binary.rb', line 41 def to_s @string.to_s end |