Class: Steep::TypeConstruction::Pair

Inherits:
Object
  • Object
show all
Defined in:
lib/steep/type_construction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, constr:) ⇒ Pair

Returns a new instance of Pair.



7
8
9
10
# File 'lib/steep/type_construction.rb', line 7

def initialize(type:, constr:)
  @type = type
  @constr = constr
end

Instance Attribute Details

#constrObject (readonly)

Returns the value of attribute constr.



5
6
7
# File 'lib/steep/type_construction.rb', line 5

def constr
  @constr
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/steep/type_construction.rb', line 4

def type
  @type
end

Instance Method Details

#+(other) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/steep/type_construction.rb', line 16

def +(other)
  if type.is_a?(AST::Types::Bot)
    other.with(type: type)
  else
    other
  end
end

#contextObject



24
25
26
# File 'lib/steep/type_construction.rb', line 24

def context
  constr.context
end

#to_aryObject



28
29
30
# File 'lib/steep/type_construction.rb', line 28

def to_ary
  [type, constr, context]
end

#with(type: self.type, constr: self.constr) ⇒ Object



12
13
14
# File 'lib/steep/type_construction.rb', line 12

def with(type: self.type, constr: self.constr)
  self.class.new(type: type, constr: constr)
end