Class: Odin::Types::OdinBinary
Instance Attribute Summary collapse
Attributes inherited from OdinValue
#directives, #modifiers
Instance Method Summary
collapse
Methods inherited from OdinValue
#array?, #binary?, #boolean?, #confidential?, #currency?, #date?, #deprecated?, #duration?, #integer?, #null?, #number?, #numeric?, #object?, #percent?, #reference?, #required?, #string?, #temporal?, #time?, #timestamp?, #verb?
Constructor Details
#initialize(data, algorithm: nil, **kwargs) ⇒ OdinBinary
Returns a new instance of OdinBinary.
463
464
465
466
467
468
|
# File 'lib/odin/types/values.rb', line 463
def initialize(data, algorithm: nil, **kwargs)
super(**kwargs)
@data = data.freeze
@algorithm = algorithm&.freeze
freeze
end
|
Instance Attribute Details
#algorithm ⇒ Object
Returns the value of attribute algorithm.
461
462
463
|
# File 'lib/odin/types/values.rb', line 461
def algorithm
@algorithm
end
|
#data ⇒ Object
Returns the value of attribute data.
461
462
463
|
# File 'lib/odin/types/values.rb', line 461
def data
@data
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
472
473
474
|
# File 'lib/odin/types/values.rb', line 472
def ==(other)
other.is_a?(OdinBinary) && data == other.data && algorithm == other.algorithm
end
|
#hash ⇒ Object
477
478
479
|
# File 'lib/odin/types/values.rb', line 477
def hash
[ValueType::BINARY, data, algorithm].hash
end
|
#to_s ⇒ Object
481
482
483
|
# File 'lib/odin/types/values.rb', line 481
def to_s
algorithm ? "^#{algorithm}:#{data}" : "^#{data}"
end
|
#type ⇒ Object
470
|
# File 'lib/odin/types/values.rb', line 470
def type; ValueType::BINARY; end
|
#with_directives(dirs) ⇒ Object
489
490
491
|
# File 'lib/odin/types/values.rb', line 489
def with_directives(dirs)
OdinBinary.new(data, algorithm: algorithm, modifiers: modifiers, directives: dirs)
end
|
#with_modifiers(mods) ⇒ Object
485
486
487
|
# File 'lib/odin/types/values.rb', line 485
def with_modifiers(mods)
OdinBinary.new(data, algorithm: algorithm, modifiers: mods, directives: directives)
end
|