Class: Spoom::Poset::Element
- Inherits:
-
Object
- Object
- Spoom::Poset::Element
- Includes:
- Comparable
- Defined in:
- lib/spoom/poset.rb
Overview
An element in a POSet : [E < 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
145 146 147 148 149 150 151 |
# File 'lib/spoom/poset.rb', line 145 def initialize(value) @value = value @dtos = Set.new #: Set[Element[E]] @tos = Set.new #: Set[Element[E]] @dfroms = Set.new #: Set[Element[E]] @froms = Set.new #: 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]
142 143 144 |
# File 'lib/spoom/poset.rb', line 142 def dfroms @dfroms end |
#dtos ⇒ Object (readonly)
Edges (direct and indirect) from this element to other elements in the same POSet : Set[Element]
142 143 144 |
# File 'lib/spoom/poset.rb', line 142 def dtos @dtos end |
#froms ⇒ Object (readonly)
Edges (direct and indirect) from this element to other elements in the same POSet : Set[Element]
142 143 144 |
# File 'lib/spoom/poset.rb', line 142 def froms @froms end |
#tos ⇒ Object (readonly)
Edges (direct and indirect) from this element to other elements in the same POSet : Set[Element]
142 143 144 |
# File 'lib/spoom/poset.rb', line 142 def tos @tos end |
#value ⇒ Object (readonly)
The value held by this element : E
138 139 140 |
# File 'lib/spoom/poset.rb', line 138 def value @value end |
Instance Method Details
#<=>(other) ⇒ Object
: (untyped other) -> Integer?
154 155 156 157 158 159 160 161 162 163 |
# File 'lib/spoom/poset.rb', line 154 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
173 174 175 |
# File 'lib/spoom/poset.rb', line 173 def ancestors @tos.map(&:value) end |
#children ⇒ Object
Direct children of this element : -> Array
179 180 181 |
# File 'lib/spoom/poset.rb', line 179 def children @dfroms.map(&:value) end |
#descendants ⇒ Object
Direct and indirect descendants of this element : -> Array
185 186 187 |
# File 'lib/spoom/poset.rb', line 185 def descendants @froms.map(&:value) end |
#parents ⇒ Object
Direct parents of this element : -> Array
167 168 169 |
# File 'lib/spoom/poset.rb', line 167 def parents @dtos.map(&:value) end |