Class: MilkTea::Types::GenericInstance

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

#initialize(name, arguments) ⇒ GenericInstance

Returns a new instance of GenericInstance.



439
440
441
442
443
444
# File 'lib/milk_tea/core/types/types.rb', line 439

def initialize(name, arguments)
  @name = name
  @arguments = arguments.freeze
  @hash = [self.class, name, @arguments].hash
  freeze
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



437
438
439
# File 'lib/milk_tea/core/types/types.rb', line 437

def arguments
  @arguments
end

#hashObject (readonly)

Returns the value of attribute hash.



452
453
454
# File 'lib/milk_tea/core/types/types.rb', line 452

def hash
  @hash
end

#nameObject (readonly)

Returns the value of attribute name.



437
438
439
# File 'lib/milk_tea/core/types/types.rb', line 437

def name
  @name
end

Instance Method Details

#childrenObject



458
459
460
# File 'lib/milk_tea/core/types/types.rb', line 458

def children
  arguments.reject { |a| a.is_a?(Types::LiteralTypeArg) }
end

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

Returns:

  • (Boolean)


446
447
448
# File 'lib/milk_tea/core/types/types.rb', line 446

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

#to_sObject



454
455
456
# File 'lib/milk_tea/core/types/types.rb', line 454

def to_s
  "#{name}[#{arguments.join(', ')}]"
end