Class: MilkTea::Types::Proc

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(params:, return_type:) ⇒ Proc

Returns a new instance of Proc.



1367
1368
1369
1370
1371
1372
# File 'lib/milk_tea/core/types/types.rb', line 1367

def initialize(params:, return_type:)
  @params = params.freeze
  @return_type = return_type
  @hash = [self.class, @params, return_type].hash
  freeze
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



1380
1381
1382
# File 'lib/milk_tea/core/types/types.rb', line 1380

def hash
  @hash
end

#paramsObject (readonly)

Returns the value of attribute params.



1365
1366
1367
# File 'lib/milk_tea/core/types/types.rb', line 1365

def params
  @params
end

#return_typeObject (readonly)

Returns the value of attribute return_type.



1365
1366
1367
# File 'lib/milk_tea/core/types/types.rb', line 1365

def return_type
  @return_type
end

Instance Method Details

#childrenObject



1386
1387
1388
# File 'lib/milk_tea/core/types/types.rb', line 1386

def children
  params.map(&:type) + [return_type]
end

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

Returns:

  • (Boolean)


1374
1375
1376
# File 'lib/milk_tea/core/types/types.rb', line 1374

def eql?(other)
  other.is_a?(Proc) && other.params == params && other.return_type == return_type
end

#to_sObject



1382
1383
1384
# File 'lib/milk_tea/core/types/types.rb', line 1382

def to_s
  "proc(#{params.map(&:type).join(', ')}) -> #{return_type}"
end