Class: MilkTea::Types::Quaternion

Inherits:
Base
  • Object
show all
Defined in:
lib/milk_tea/core/types/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.



1483
1484
1485
1486
1487
1488
1489
1490
1491
# File 'lib/milk_tea/core/types/types.rb', line 1483

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.



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

def hash
  @hash
end

#module_nameObject (readonly)

Returns the value of attribute module_name.



1479
1480
1481
# File 'lib/milk_tea/core/types/types.rb', line 1479

def module_name
  @module_name
end

#nameObject (readonly)

Returns the value of attribute name.



1479
1480
1481
# File 'lib/milk_tea/core/types/types.rb', line 1479

def name
  @name
end

Instance Method Details

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

Returns:

  • (Boolean)


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

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

#field(name) ⇒ Object



1505
1506
1507
# File 'lib/milk_tea/core/types/types.rb', line 1505

def field(name)
  @fields[name]
end

#fieldsObject



1501
1502
1503
# File 'lib/milk_tea/core/types/types.rb', line 1501

def fields
  @fields
end

#numeric?Boolean

Returns:

  • (Boolean)


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

def numeric?
  true
end

#to_sObject



1514
1515
1516
# File 'lib/milk_tea/core/types/types.rb', line 1514

def to_s
  name
end