class IcAgent::Candid::VecClass
Represents an IDL Array
Public Class Methods
new(_type)
click to toggle source
Calls superclass method
IcAgent::Candid::ConstructType::new
# File lib/ic_agent/candid.rb, line 675 def initialize(_type) super() @interior_type = _type end
Public Instance Methods
_build_type_table_impl(type_table)
click to toggle source
# File lib/ic_agent/candid.rb, line 690 def _build_type_table_impl(type_table) @interior_type.build_type_table(type_table) op_code = LEB128.encode_signed(TypeIds::Vec).string buffer = @interior_type.encode_type(type_table) type_table.add(self, op_code + buffer) end
covariant(x)
click to toggle source
# File lib/ic_agent/candid.rb, line 680 def covariant(x) x.is_a?(Enumerable) && !x.any? { |item| !@interior_type.covariant(item) } end
decode_value(b, t)
click to toggle source
# File lib/ic_agent/candid.rb, line 697 def decode_value(b, t) vec = check_type(t) raise 'Not a vector type' unless vec.is_a?(VecClass) length = IcAgent::Candid.leb128u_decode(b) rets = [] length.times { rets << @interior_type.decode_value(b, @interior_type) } rets end
display()
click to toggle source
# File lib/ic_agent/candid.rb, line 715 def display "vec #{@interior_type.display}" end
encode_value(val)
click to toggle source
# File lib/ic_agent/candid.rb, line 684 def encode_value(val) length = LEB128.encode_signed(val.length).string vec = val.map { |v| @interior_type.encode_value(v) } (length + vec.join).b end
id()
click to toggle source
# File lib/ic_agent/candid.rb, line 711 def id TypeIds::Vec end
name()
click to toggle source
# File lib/ic_agent/candid.rb, line 707 def name "vec (#{@interior_type.name})" end