Class: Spoom::Poset::Element
- Inherits:
-
Object
- Object
- Spoom::Poset::Element
- Extended by:
- T::Generic
- 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
Edges (direct and indirect) from this element to other elements in the same POSet : Set[Element].
-
#dtos ⇒ Object
readonly
Edges (direct and indirect) from this element to other elements in the same POSet : Set[Element].
-
#froms ⇒ Object
readonly
Edges (direct and indirect) from this element to other elements in the same POSet : Set[Element].
-
#tos ⇒ Object
readonly
Edges (direct and indirect) from this element to other elements in the same POSet : Set[Element].
-
#value ⇒ Object
readonly
The value held by this element : E.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
: (untyped other) -> Integer?.
-
#ancestors ⇒ Object
Direct and indirect ancestors of this element : -> Array.
-
#children ⇒ Object
Direct children of this element : -> Array.
-
#descendants ⇒ Object
Direct and indirect descendants of this element : -> Array.
-
#initialize(value) ⇒ Element
constructor
: (E value) -> void.
-
#parents ⇒ Object
Direct parents of this element : -> Array.
Constructor Details
#initialize(value) ⇒ Element
: (E value) -> void
150 151 152 153 154 155 156 |
# File 'lib/spoom/poset.rb', line 150 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)
Edges (direct and indirect) from this element to other elements in the same POSet : Set[Element]
147 148 149 |
# File 'lib/spoom/poset.rb', line 147 def dfroms @dfroms end |
#dtos ⇒ Object (readonly)
Edges (direct and indirect) from this element to other elements in the same POSet : Set[Element]
147 148 149 |
# File 'lib/spoom/poset.rb', line 147 def dtos @dtos end |
#froms ⇒ Object (readonly)
Edges (direct and indirect) from this element to other elements in the same POSet : Set[Element]
147 148 149 |
# File 'lib/spoom/poset.rb', line 147 def froms @froms end |
#tos ⇒ Object (readonly)
Edges (direct and indirect) from this element to other elements in the same POSet : Set[Element]
147 148 149 |
# File 'lib/spoom/poset.rb', line 147 def tos @tos end |
#value ⇒ Object (readonly)
The value held by this element : E
143 144 145 |
# File 'lib/spoom/poset.rb', line 143 def value @value end |
Instance Method Details
#<=>(other) ⇒ Object
: (untyped other) -> Integer?
159 160 161 162 163 164 165 166 167 168 |
# File 'lib/spoom/poset.rb', line 159 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
Direct and indirect ancestors of this element : -> Array
178 179 180 |
# File 'lib/spoom/poset.rb', line 178 def ancestors @tos.map(&:value) end |
#children ⇒ Object
Direct children of this element : -> Array
184 185 186 |
# File 'lib/spoom/poset.rb', line 184 def children @dfroms.map(&:value) end |
#descendants ⇒ Object
Direct and indirect descendants of this element : -> Array
190 191 192 |
# File 'lib/spoom/poset.rb', line 190 def descendants @froms.map(&:value) end |
#parents ⇒ Object
Direct parents of this element : -> Array
172 173 174 |
# File 'lib/spoom/poset.rb', line 172 def parents @dtos.map(&:value) end |