class Ciri::Types::Hash32
Public Class Methods
new(h)
click to toggle source
# File lib/ciri/types/hash.rb, line 45 def initialize(h) @hash32 = h.to_s end
rlp_decode(data)
click to toggle source
# File lib/ciri/types/hash.rb, line 36 def rlp_decode(data) hash32 = self.new(RLP.decode(data)) hash32.validate hash32 end
rlp_encode(hash32)
click to toggle source
# File lib/ciri/types/hash.rb, line 32 def rlp_encode(hash32) RLP.encode(hash32.to_s) end
Public Instance Methods
==(other)
click to toggle source
# File lib/ciri/types/hash.rb, line 49 def ==(other) self.class == other.class && to_s == other.to_s end
empty?()
click to toggle source
# File lib/ciri/types/hash.rb, line 63 def empty? @hash32.empty? end
to_hex()
click to toggle source
# File lib/ciri/types/hash.rb, line 59 def to_hex Utils.to_hex to_s end
to_s()
click to toggle source
# File lib/ciri/types/hash.rb, line 53 def to_s @hash32 end
Also aliased as: to_str
validate()
click to toggle source
# File lib/ciri/types/hash.rb, line 67 def validate # empty address is valid return if empty? raise InvalidError.new("hash32 must be 32 size, got #{@hash32.size}") unless @hash32.size == 32 end