Class: Steep::TypeConstruction::Pair
- Inherits:
-
Object
- Object
- Steep::TypeConstruction::Pair
- Defined in:
- lib/steep/type_construction.rb
Instance Attribute Summary collapse
-
#constr ⇒ Object
readonly
Returns the value of attribute constr.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #+(other) ⇒ Object
- #context ⇒ Object
-
#initialize(type:, constr:) ⇒ Pair
constructor
A new instance of Pair.
- #to_ary ⇒ Object
- #with(type: self.type, constr: self.constr) ⇒ Object
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
#constr ⇒ Object (readonly)
Returns the value of attribute constr.
5 6 7 |
# File 'lib/steep/type_construction.rb', line 5 def constr @constr end |
#type ⇒ Object (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 |
#context ⇒ Object
27 28 29 |
# File 'lib/steep/type_construction.rb', line 27 def context constr.context end |
#to_ary ⇒ Object
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 |