Class: MilkTea::Types::VariantInstance
- Defined in:
- lib/milk_tea/core/types/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.
1151 1152 1153 1154 1155 1156 |
# File 'lib/milk_tea/core/types/types.rb', line 1151 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.
1149 1150 1151 |
# File 'lib/milk_tea/core/types/types.rb', line 1149 def arguments @arguments end |
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
1149 1150 1151 |
# File 'lib/milk_tea/core/types/types.rb', line 1149 def definition @definition end |
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
1164 1165 1166 |
# File 'lib/milk_tea/core/types/types.rb', line 1164 def hash @hash end |
Instance Method Details
#children ⇒ Object
1171 1172 1173 |
# File 'lib/milk_tea/core/types/types.rb', line 1171 def children arm_names.flat_map { |a| arm(a).values } end |
#eql?(other) ⇒ Boolean Also known as: ==
1158 1159 1160 |
# File 'lib/milk_tea/core/types/types.rb', line 1158 def eql?(other) other.is_a?(VariantInstance) && other.definition == definition && other.arguments == arguments end |
#to_s ⇒ Object
1166 1167 1168 1169 |
# File 'lib/milk_tea/core/types/types.rb', line 1166 def to_s base = module_name ? "#{module_name}.#{name}" : name "#{base}[#{arguments.join(', ')}]" end |