Class: IcAgent::Candid::NatClass

Inherits:
PrimitiveType show all
Defined in:
lib/ic_agent/candid.rb

Instance Method Summary collapse

Methods inherited from PrimitiveType

#_build_type_table_impl, #check_type

Methods inherited from BaseType

_build_type_table_impl, #build_type_table, check_type, covariant, decode_value, #display, encode_type, encode_value

Constructor Details

#initializeNatClass

Returns a new instance of NatClass.



378
379
380
# File 'lib/ic_agent/candid.rb', line 378

def initialize
  super
end

Instance Method Details

#covariant(x) ⇒ Object



382
383
384
# File 'lib/ic_agent/candid.rb', line 382

def covariant(x)
  x.is_a?(Integer) && x >= 0
end

#decode_value(pipe, t) ⇒ Object



394
395
396
397
# File 'lib/ic_agent/candid.rb', line 394

def decode_value(pipe, t)
  check_type(t)
  IcAgent::Candid.leb128u_decode(pipe)
end

#encode_type(type_table = nil) ⇒ Object



390
391
392
# File 'lib/ic_agent/candid.rb', line 390

def encode_type(type_table = nil)
  LEB128.encode_signed(TypeIds::Nat).string
end

#encode_value(val) ⇒ Object



386
387
388
# File 'lib/ic_agent/candid.rb', line 386

def encode_value(val)
  LEB128.encode_signed(val).string
end

#idObject



403
404
405
# File 'lib/ic_agent/candid.rb', line 403

def id
  TypeIds::Nat
end

#nameObject



399
400
401
# File 'lib/ic_agent/candid.rb', line 399

def name
  'nat'
end