Class: BinaryCodec::Hash128

Inherits:
Hash show all
Defined in:
lib/binary-codec/types/hash.rb

Instance Attribute Summary

Attributes inherited from SerializedType

#bytes

Instance Method Summary collapse

Methods inherited from Hash

#compare_to, from, from_parser, #nibblet, width

Methods inherited from ComparableSerializedType

#compare_to, #eq, #gt, #gte, #lt, #lte

Methods inherited from SerializedType

from, from_bytes, from_hex, from_json, from_parser, get_type_by_name, #to_byte_sink, #to_bytes, #to_json, #value_of

Constructor Details

#initialize(bytes = nil) ⇒ Hash128

Returns a new instance of Hash128.



71
72
73
# File 'lib/binary-codec/types/hash.rb', line 71

def initialize(bytes = nil)
  super(bytes)
end

Instance Method Details

#to_hexObject



75
76
77
78
79
# File 'lib/binary-codec/types/hash.rb', line 75

def to_hex
  hex = bytes_to_hex(to_bytes)
  return '' if hex.match?(/^0+$/)
  hex
end