Class: Radiator::Type::Beneficiaries
Instance Method Summary
collapse
Methods included from Utils
#debug, #error, #extract_signatures, #hexlify, #pakArr, #pakC, #pakHash, #pakI, #pakL!, #pakS, #pakStr, #pakc, #paks, #send_log, #unhexlify, #varint, #warning
Constructor Details
Returns a new instance of Beneficiaries.
5
6
7
|
# File 'lib/radiator/type/beneficiaries.rb', line 5
def initialize(value)
super(:beneficiaries, value)
end
|
Instance Method Details
#to_bytes ⇒ Object
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/radiator/type/beneficiaries.rb', line 9
def to_bytes
varint(1) + varint(0) + varint(@value.size) + @value.map do |b|
case b
when ::Array then pakStr(b.first.to_s) + pakS(b.last)
else; pakStr(b.keys.first.to_s) + pakS(b.values.first)
end
end.join
end
|
#to_h ⇒ Object
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/radiator/type/beneficiaries.rb', line 20
def to_h
v = @value.map do |b|
case b
when ::Array then {account: b.first, weight: b.last}
else; {account: b.keys.first, weight: b.values.first}
end
end
{@key => v}
end
|
#to_s ⇒ Object
31
32
33
|
# File 'lib/radiator/type/beneficiaries.rb', line 31
def to_s
to_h.to_json
end
|