Class: MilkTea::Types::Quaternion

Inherits:
Base
  • Object
show all
Defined in:
lib/milk_tea/core/types.rb

Constant Summary collapse

FIELD_NAMES =
%w[x y z w].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#accept, #bitwise?, #boolean?, #children, #field_c_name, #float?, #integer?, #sendable?, #void?

Constructor Details

#initialize(name) ⇒ Quaternion

Returns a new instance of Quaternion.



1472
1473
1474
1475
1476
1477
1478
1479
1480
# File 'lib/milk_tea/core/types.rb', line 1472

def initialize(name)
  @name = name
  @module_name = nil
  @fields = FIELD_NAMES.each_with_object({}) do |fname, h|
    h[fname] = BUILTIN_VECTOR_ELEMENT
  end.freeze
  @hash = [self.class, name].hash
  freeze
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



1488
1489
1490
# File 'lib/milk_tea/core/types.rb', line 1488

def hash
  @hash
end

#module_nameObject (readonly)

Returns the value of attribute module_name.



1468
1469
1470
# File 'lib/milk_tea/core/types.rb', line 1468

def module_name
  @module_name
end

#nameObject (readonly)

Returns the value of attribute name.



1468
1469
1470
# File 'lib/milk_tea/core/types.rb', line 1468

def name
  @name
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


1482
1483
1484
# File 'lib/milk_tea/core/types.rb', line 1482

def eql?(other)
  other.is_a?(Quaternion) && other.name == name
end

#field(name) ⇒ Object



1494
1495
1496
# File 'lib/milk_tea/core/types.rb', line 1494

def field(name)
  @fields[name]
end

#fieldsObject



1490
1491
1492
# File 'lib/milk_tea/core/types.rb', line 1490

def fields
  @fields
end

#numeric?Boolean

Returns:

  • (Boolean)


1498
1499
1500
# File 'lib/milk_tea/core/types.rb', line 1498

def numeric?
  true
end

#to_sObject



1503
1504
1505
# File 'lib/milk_tea/core/types.rb', line 1503

def to_s
  name
end