Class: IcAgent::Candid::EmptyClass

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

Overview

Represents an IDL Empty, a type which has no inhabitants.

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

#initializeEmptyClass

Returns a new instance of EmptyClass.



212
213
214
# File 'lib/ic_agent/candid.rb', line 212

def initialize
  super
end

Instance Method Details

#covariant(x) ⇒ Object



216
217
218
# File 'lib/ic_agent/candid.rb', line 216

def covariant(x)
  false
end

#decode_value(b, t) ⇒ Object

Raises:



228
229
230
# File 'lib/ic_agent/candid.rb', line 228

def decode_value(b, t)
  raise ValueError, 'Empty cannot appear as an output'
end

#encode_type(type_table = nil) ⇒ Object



224
225
226
# File 'lib/ic_agent/candid.rb', line 224

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

#encode_value(val) ⇒ Object

Raises:



220
221
222
# File 'lib/ic_agent/candid.rb', line 220

def encode_value(val)
  raise ValueError, 'Empty cannot appear as a function argument'
end

#idObject



236
237
238
# File 'lib/ic_agent/candid.rb', line 236

def id
  TypeIds::Empty
end

#nameObject



232
233
234
# File 'lib/ic_agent/candid.rb', line 232

def name
  'empty'
end