Class: MilkTea::Types::VariantInstance
- Defined in:
- lib/milk_tea/core/types.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
Attributes inherited from Variant
Instance Method Summary collapse
- #children ⇒ Object
- #eql?(other) ⇒ Boolean (also: #==)
-
#initialize(definition, arguments) ⇒ VariantInstance
constructor
A new instance of VariantInstance.
- #to_s ⇒ Object
Methods inherited from Variant
#arm, #arm_names, #define_arms, #has_payload?
Methods inherited from Base
#accept, #bitwise?, #boolean?, #field_c_name, #float?, #integer?, #numeric?, #sendable?, #void?
Constructor Details
#initialize(definition, arguments) ⇒ VariantInstance
Returns a new instance of VariantInstance.
1140 1141 1142 1143 1144 1145 |
# File 'lib/milk_tea/core/types.rb', line 1140 def initialize(definition, arguments) super(definition.name, module_name: definition.module_name) @definition = definition @arguments = arguments.freeze @hash = [self.class, definition, @arguments].hash end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
1138 1139 1140 |
# File 'lib/milk_tea/core/types.rb', line 1138 def arguments @arguments end |
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
1138 1139 1140 |
# File 'lib/milk_tea/core/types.rb', line 1138 def definition @definition end |
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
1153 1154 1155 |
# File 'lib/milk_tea/core/types.rb', line 1153 def hash @hash end |
Instance Method Details
#children ⇒ Object
1160 1161 1162 |
# File 'lib/milk_tea/core/types.rb', line 1160 def children arm_names.flat_map { |a| arm(a).values } end |
#eql?(other) ⇒ Boolean Also known as: ==
1147 1148 1149 |
# File 'lib/milk_tea/core/types.rb', line 1147 def eql?(other) other.is_a?(VariantInstance) && other.definition == definition && other.arguments == arguments end |
#to_s ⇒ Object
1155 1156 1157 1158 |
# File 'lib/milk_tea/core/types.rb', line 1155 def to_s base = module_name ? "#{module_name}.#{name}" : name "#{base}[#{arguments.join(', ')}]" end |