Class: Spoom::Poset::Element
- Inherits:
-
Object
- Object
- Spoom::Poset::Element
- Extended by:
- T::Generic, T::Sig
- Includes:
- Comparable
- Defined in:
- lib/spoom/poset.rb
Overview
An element in a POSet
Constant Summary collapse
- E =
type_member { { upper: Object } }
Instance Attribute Summary collapse
-
#dfroms ⇒ Object
readonly
Returns the value of attribute dfroms.
-
#dtos ⇒ Object
readonly
Returns the value of attribute dtos.
-
#froms ⇒ Object
readonly
Returns the value of attribute froms.
-
#tos ⇒ Object
readonly
Returns the value of attribute tos.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #ancestors ⇒ Object
- #children ⇒ Object
- #descendants ⇒ Object
-
#initialize(value) ⇒ Element
constructor
A new instance of Element.
- #parents ⇒ Object
Constructor Details
#initialize(value) ⇒ Element
Returns a new instance of Element.
152 153 154 155 156 157 158 |
# File 'lib/spoom/poset.rb', line 152 def initialize(value) @value = value @dtos = T.let(Set.new, T::Set[Element[E]]) @tos = T.let(Set.new, T::Set[Element[E]]) @dfroms = T.let(Set.new, T::Set[Element[E]]) @froms = T.let(Set.new, T::Set[Element[E]]) end |
Instance Attribute Details
#dfroms ⇒ Object (readonly)
Returns the value of attribute dfroms.
149 150 151 |
# File 'lib/spoom/poset.rb', line 149 def dfroms @dfroms end |
#dtos ⇒ Object (readonly)
Returns the value of attribute dtos.
149 150 151 |
# File 'lib/spoom/poset.rb', line 149 def dtos @dtos end |
#froms ⇒ Object (readonly)
Returns the value of attribute froms.
149 150 151 |
# File 'lib/spoom/poset.rb', line 149 def froms @froms end |
#tos ⇒ Object (readonly)
Returns the value of attribute tos.
149 150 151 |
# File 'lib/spoom/poset.rb', line 149 def tos @tos end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
145 146 147 |
# File 'lib/spoom/poset.rb', line 145 def value @value end |
Instance Method Details
#<=>(other) ⇒ Object
161 162 163 164 165 166 167 168 169 170 |
# File 'lib/spoom/poset.rb', line 161 def <=>(other) return unless other.is_a?(Element) return 0 if self == other if tos.include?(other) -1 elsif froms.include?(other) 1 end end |
#ancestors ⇒ Object
180 181 182 |
# File 'lib/spoom/poset.rb', line 180 def ancestors @tos.map(&:value) end |
#children ⇒ Object
186 187 188 |
# File 'lib/spoom/poset.rb', line 186 def children @dfroms.map(&:value) end |
#descendants ⇒ Object
192 193 194 |
# File 'lib/spoom/poset.rb', line 192 def descendants @froms.map(&:value) end |
#parents ⇒ Object
174 175 176 |
# File 'lib/spoom/poset.rb', line 174 def parents @dtos.map(&:value) end |