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
-
#ancestor_pieces ⇒ Array <Cardname>
-
#ancestors ⇒ Array <String>
parents, parents’ parents, etc.
-
#piece_names ⇒ Array <Cardname>
-
#pieces ⇒ Array <String>
self and all ancestors (= parts and recursive lefts).
Instance Method Details
#ancestor_pieces ⇒ Array <Cardname>
30 31 32 |
# File 'cardname/lib/cardname/pieces.rb', line 30 def ancestor_pieces ancestors.map(&:to_name) end |
#ancestors ⇒ Array <String>
parents, parents’ parents, etc
24 25 26 |
# File 'cardname/lib/cardname/pieces.rb', line 24 def ancestors pieces.reject { |p| p == self } end |
#piece_names ⇒ Array <Cardname>
16 17 18 |
# File 'cardname/lib/cardname/pieces.rb', line 16 def piece_names pieces.map(&:to_name) end |
#pieces ⇒ Array <String>
self and all ancestors (= parts and recursive lefts)
10 11 12 |
# File 'cardname/lib/cardname/pieces.rb', line 10 def pieces simple? ? [self] : (parts + compound_pieces) end |