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



19
20
21
22
23
24
25
# File 'lib/steep/type_construction.rb', line 19

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

#contextObject



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

def context
  constr.context
end

#to_aryObject



31
32
33
# File 'lib/steep/type_construction.rb', line 31

def to_ary
  [type, constr, context]
end

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



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

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