Class: MilkTea::Types::Vector
- Defined in:
- lib/milk_tea/core/types/types.rb
Constant Summary collapse
- FIELD_NAMES =
%w[x y z w].freeze
Instance Attribute Summary collapse
-
#element_type ⇒ Object
readonly
Returns the value of attribute element_type.
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#module_name ⇒ Object
readonly
Returns the value of attribute module_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
- #field(name) ⇒ Object
- #fields ⇒ Object
-
#initialize(name, element_type:, width:) ⇒ Vector
constructor
A new instance of Vector.
- #numeric? ⇒ Boolean
- #to_s ⇒ Object
Methods inherited from Base
#accept, #bitwise?, #boolean?, #children, #field_c_name, #float?, #integer?, #sendable?, #void?
Constructor Details
#initialize(name, element_type:, width:) ⇒ Vector
Returns a new instance of Vector.
1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 |
# File 'lib/milk_tea/core/types/types.rb', line 1399 def initialize(name, element_type:, width:) @name = name @element_type = element_type @width = width @module_name = nil @fields = FIELD_NAMES.first(width).each_with_object({}) do |fname, h| h[fname] = element_type end.freeze @hash = [self.class, name, element_type].hash freeze end |
Instance Attribute Details
#element_type ⇒ Object (readonly)
Returns the value of attribute element_type.
1395 1396 1397 |
# File 'lib/milk_tea/core/types/types.rb', line 1395 def element_type @element_type end |
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
1417 1418 1419 |
# File 'lib/milk_tea/core/types/types.rb', line 1417 def hash @hash end |
#module_name ⇒ Object (readonly)
Returns the value of attribute module_name.
1395 1396 1397 |
# File 'lib/milk_tea/core/types/types.rb', line 1395 def module_name @module_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
1395 1396 1397 |
# File 'lib/milk_tea/core/types/types.rb', line 1395 def name @name end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
1395 1396 1397 |
# File 'lib/milk_tea/core/types/types.rb', line 1395 def width @width end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
1411 1412 1413 |
# File 'lib/milk_tea/core/types/types.rb', line 1411 def eql?(other) other.is_a?(Vector) && other.name == name && other.element_type == element_type end |
#field(name) ⇒ Object
1423 1424 1425 |
# File 'lib/milk_tea/core/types/types.rb', line 1423 def field(name) @fields[name] end |
#fields ⇒ Object
1419 1420 1421 |
# File 'lib/milk_tea/core/types/types.rb', line 1419 def fields @fields end |
#numeric? ⇒ Boolean
1427 1428 1429 |
# File 'lib/milk_tea/core/types/types.rb', line 1427 def numeric? true end |
#to_s ⇒ Object
1432 1433 1434 |
# File 'lib/milk_tea/core/types/types.rb', line 1432 def to_s name end |