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.



1477
1478
1479
1480
1481
1482
1483
1484
1485
# File 'lib/milk_tea/core/types.rb', line 1477

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.



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

def hash
  @hash
end

#module_nameObject (readonly)

Returns the value of attribute module_name.



1473
1474
1475
# File 'lib/milk_tea/core/types.rb', line 1473

def module_name
  @module_name
end

#nameObject (readonly)

Returns the value of attribute name.



1473
1474
1475
# File 'lib/milk_tea/core/types.rb', line 1473

def name
  @name
end

Instance Method Details

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

Returns:

  • (Boolean)


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

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

#field(name) ⇒ Object



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

def field(name)
  @fields[name]
end

#fieldsObject



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

def fields
  @fields
end

#numeric?Boolean

Returns:

  • (Boolean)


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

def numeric?
  true
end

#to_sObject



1508
1509
1510
# File 'lib/milk_tea/core/types.rb', line 1508

def to_s
  name
end