Class: MilkTea::Types::Proc

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



1361
1362
1363
1364
1365
1366
# File 'lib/milk_tea/core/types.rb', line 1361

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.



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

def hash
  @hash
end

#paramsObject (readonly)

Returns the value of attribute params.



1359
1360
1361
# File 'lib/milk_tea/core/types.rb', line 1359

def params
  @params
end

#return_typeObject (readonly)

Returns the value of attribute return_type.



1359
1360
1361
# File 'lib/milk_tea/core/types.rb', line 1359

def return_type
  @return_type
end

Instance Method Details

#childrenObject



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

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

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

Returns:

  • (Boolean)


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

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

#to_sObject



1376
1377
1378
# File 'lib/milk_tea/core/types.rb', line 1376

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