Class: Steep::Subtyping::Relation
- Inherits:
-
Object
- Object
- Steep::Subtyping::Relation
- Defined in:
- lib/steep/subtyping/relation.rb
Instance Attribute Summary collapse
-
#sub_type ⇒ Object
readonly
Returns the value of attribute sub_type.
-
#super_type ⇒ Object
readonly
Returns the value of attribute super_type.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #flip ⇒ Object
- #hash ⇒ Object
-
#initialize(sub_type:, super_type:) ⇒ Relation
constructor
A new instance of Relation.
- #map ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(sub_type:, super_type:) ⇒ Relation
Returns a new instance of Relation.
7 8 9 10 |
# File 'lib/steep/subtyping/relation.rb', line 7 def initialize(sub_type:, super_type:) @sub_type = sub_type @super_type = super_type end |
Instance Attribute Details
#sub_type ⇒ Object (readonly)
Returns the value of attribute sub_type.
4 5 6 |
# File 'lib/steep/subtyping/relation.rb', line 4 def sub_type @sub_type end |
#super_type ⇒ Object (readonly)
Returns the value of attribute super_type.
5 6 7 |
# File 'lib/steep/subtyping/relation.rb', line 5 def super_type @super_type end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
16 17 18 |
# File 'lib/steep/subtyping/relation.rb', line 16 def ==(other) other.is_a?(self.class) && other.sub_type == sub_type && other.super_type == super_type end |
#flip ⇒ Object
33 34 35 36 37 38 |
# File 'lib/steep/subtyping/relation.rb', line 33 def flip self.class.new( sub_type: super_type, super_type: sub_type ) end |
#hash ⇒ Object
12 13 14 |
# File 'lib/steep/subtyping/relation.rb', line 12 def hash self.class.hash ^ sub_type.hash ^ super_type.hash end |
#map ⇒ Object
26 27 28 29 30 31 |
# File 'lib/steep/subtyping/relation.rb', line 26 def map self.class.new( sub_type: yield(sub_type), super_type: yield(super_type) ) end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/steep/subtyping/relation.rb', line 22 def to_s "#{sub_type} <: #{super_type}" end |