Module: Cardname::Pieces
- Included in:
- Cardname
- Defined in:
- cardname/lib/cardname/pieces.rb
Overview
Cards never have more than two “parts” (left and right), but they can have many “pieces”. A card’s pieces are all the other cards whose existence its existence implies. For example if A+B+C exists, that implies that A, B, C, and A+B do too.
Instance Method Summary collapse
-
#ancestors ⇒ Object
-
#piece_names ⇒ Object
-
#pieces ⇒ Object
self and all ancestors (= parts and recursive lefts).
Instance Method Details
#ancestors ⇒ Object
18 19 20 |
# File 'cardname/lib/cardname/pieces.rb', line 18 def ancestors pieces.reject { |p| p == self } end |
#piece_names ⇒ Object
14 15 16 |
# File 'cardname/lib/cardname/pieces.rb', line 14 def piece_names pieces.map(&:to_name) end |
#pieces ⇒ Object
self and all ancestors (= parts and recursive lefts)
10 11 12 |
# File 'cardname/lib/cardname/pieces.rb', line 10 def pieces simple? ? [self] : (parts + junction_pieces) end |