Class: BinaryCodec::Hash160

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

Direct Known Subclasses

AccountId, Currency

Class Attribute Summary collapse

Attributes inherited from SerializedType

#bytes

Instance Method Summary collapse

Methods inherited from Hash

#compare_to, from, from_parser, #nibblet

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_hex, #to_json, #to_s

Constructor Details

#initialize(bytes = nil) ⇒ Hash160



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

def initialize(bytes = nil)
  bytes = self.class.zero_160 if bytes&.empty?
  super(bytes, self.class.width)
end

Class Attribute Details

.widthObject (readonly)

Returns the value of attribute width.



68
69
70
# File 'lib/binary-codec/types/hash.rb', line 68

def width
  @width
end

.zero_160Object (readonly)

Returns the value of attribute zero_160.



68
69
70
# File 'lib/binary-codec/types/hash.rb', line 68

def zero_160
  @zero_160
end