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

Instance Method Details

#piecesObject

self and all ancestors (= parts and recursive lefts)

Examples:

"A+B+C+D".to_name.pieces
# => ["A", "B", "C", "D", "A+B", "A+B+C", "A+B+C+D"]


10
11
12
# File 'cardname/lib/cardname/pieces.rb', line 10

def pieces
  @pieces ||= simple? ? [self] : (parts + junction_pieces)
end