Class: Wasmtime::Component::Variant
- Inherits:
-
Object
- Object
- Wasmtime::Component::Variant
- Defined in:
- lib/wasmtime/component.rb
Overview
Represents a value for component model’s variant case. A variant case has a name that uniquely identify the case within the variant and optionally a value.
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The name of the variant case.
-
#value ⇒ Object
readonly
The optional payload of the variant case.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(name, value = nil) ⇒ Variant
constructor
A new instance of Variant.
Constructor Details
#initialize(name, value = nil) ⇒ Variant
Returns a new instance of Variant.
112 113 114 115 |
# File 'lib/wasmtime/component.rb', line 112 def initialize(name, value = nil) @name = name @value = value end |
Instance Attribute Details
#name ⇒ String (readonly)
The name of the variant case
104 105 106 |
# File 'lib/wasmtime/component.rb', line 104 def name @name end |
#value ⇒ Object (readonly)
The optional payload of the variant case
108 109 110 |
# File 'lib/wasmtime/component.rb', line 108 def value @value end |
Instance Method Details
#==(other) ⇒ Object
117 118 119 |
# File 'lib/wasmtime/component.rb', line 117 def ==(other) eql?(other) end |
#eql?(other) ⇒ Boolean
121 122 123 124 125 |
# File 'lib/wasmtime/component.rb', line 121 def eql?(other) self.class == other.class && name == other.name && value == other.value end |
#hash ⇒ Object
127 128 129 |
# File 'lib/wasmtime/component.rb', line 127 def hash [self.class, @name, @value].hash end |