Class: IcAgent::Candid::IntClass

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

Overview

Represents an IDL Int

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

#initializeIntClass

Returns a new instance of IntClass.



354
355
356
# File 'lib/ic_agent/candid.rb', line 354

def initialize
  super
end

Instance Method Details

#covariant(x) ⇒ Object



358
359
360
# File 'lib/ic_agent/candid.rb', line 358

def covariant(x)
  x.is_a?(Integer)
end

#decode_value(b, t) ⇒ Object



370
371
372
373
# File 'lib/ic_agent/candid.rb', line 370

def decode_value(b, t)
  check_type(t)
  IcAgent::Candid.leb128i_decode(b)
end

#encode_type(type_table = nil) ⇒ Object



366
367
368
# File 'lib/ic_agent/candid.rb', line 366

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

#encode_value(val) ⇒ Object



362
363
364
# File 'lib/ic_agent/candid.rb', line 362

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

#idObject



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

def id
  TypeIds::Int
end

#nameObject



375
376
377
# File 'lib/ic_agent/candid.rb', line 375

def name
  'int'
end