Class: MilkTea::Types::Parameter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, mutable: false, passing_mode: :plain, boundary_type: nil) ⇒ Parameter

Returns a new instance of Parameter.



1289
1290
1291
1292
1293
1294
1295
1296
1297
# File 'lib/milk_tea/core/types/types.rb', line 1289

def initialize(name, type, mutable: false, passing_mode: :plain, boundary_type: nil)
  @name = name
  @type = type
  @mutable = mutable
  @passing_mode = passing_mode
  @boundary_type = boundary_type
  @hash = [self.class, type, mutable, passing_mode, boundary_type].hash
  freeze
end

Instance Attribute Details

#boundary_typeObject (readonly)

Returns the value of attribute boundary_type.



1287
1288
1289
# File 'lib/milk_tea/core/types/types.rb', line 1287

def boundary_type
  @boundary_type
end

#hashObject (readonly)

Returns the value of attribute hash.



1313
1314
1315
# File 'lib/milk_tea/core/types/types.rb', line 1313

def hash
  @hash
end

#mutableObject (readonly)

Returns the value of attribute mutable.



1287
1288
1289
# File 'lib/milk_tea/core/types/types.rb', line 1287

def mutable
  @mutable
end

#nameObject (readonly)

Returns the value of attribute name.



1287
1288
1289
# File 'lib/milk_tea/core/types/types.rb', line 1287

def name
  @name
end

#passing_modeObject (readonly)

Returns the value of attribute passing_mode.



1287
1288
1289
# File 'lib/milk_tea/core/types/types.rb', line 1287

def passing_mode
  @passing_mode
end

#typeObject (readonly)

Returns the value of attribute type.



1287
1288
1289
# File 'lib/milk_tea/core/types/types.rb', line 1287

def type
  @type
end

Instance Method Details

#childrenObject



1315
1316
1317
# File 'lib/milk_tea/core/types/types.rb', line 1315

def children
  [type, boundary_type].compact
end

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

Returns:

  • (Boolean)


1303
1304
1305
1306
1307
1308
1309
# File 'lib/milk_tea/core/types/types.rb', line 1303

def eql?(other)
  other.is_a?(Parameter) &&
    other.type == type &&
    other.mutable == mutable &&
    other.passing_mode == passing_mode &&
    other.boundary_type == boundary_type
end

#to_sObject



1299
1300
1301
# File 'lib/milk_tea/core/types/types.rb', line 1299

def to_s
  "#{name}: #{type}"
end