Class: IcAgent::Candid::ConstructType
- Defined in:
- lib/ic_agent/candid.rb
Direct Known Subclasses
FuncClass, OptClass, RecClass, RecordClass, ServiceClass, VariantClass, VecClass
Instance Method Summary collapse
- #check_type(t) ⇒ Object
- #encode_type(type_table) ⇒ Object
-
#initialize ⇒ ConstructType
constructor
A new instance of ConstructType.
Methods inherited from BaseType
_build_type_table_impl, #build_type_table, check_type, covariant, decode_value, #display, encode_type, encode_value
Constructor Details
#initialize ⇒ ConstructType
Returns a new instance of ConstructType.
155 156 157 |
# File 'lib/ic_agent/candid.rb', line 155 def initialize super end |
Instance Method Details
#check_type(t) ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/ic_agent/candid.rb', line 159 def check_type(t) if t.is_a?(RecClass) ty = t.get_type() if ty == nil raise ValueError, 'type mismatch with uninitialized type' end return ty else raise ValueError, "type mismatch: type on the wire #{t.name}, expect type #{self.name}" end end |
#encode_type(type_table) ⇒ Object
172 173 174 |
# File 'lib/ic_agent/candid.rb', line 172 def encode_type(type_table) return type_table.index_of(self.name) end |