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

#ancestor_piecesArray <Cardname>

Returns:

See Also:



30
31
32
# File 'cardname/lib/cardname/pieces.rb', line 30

def ancestor_pieces
  ancestors.map(&:to_name)
end

#ancestorsArray <String>

parents, parents’ parents, etc

Examples:

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

Returns:

  • (Array <String>)


24
25
26
# File 'cardname/lib/cardname/pieces.rb', line 24

def ancestors
  pieces.reject { |p| p == self }
end

#piece_namesArray <Cardname>

Returns:

See Also:



16
17
18
# File 'cardname/lib/cardname/pieces.rb', line 16

def piece_names
  pieces.map(&:to_name)
end

#piecesArray <String>

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"]

Returns:

  • (Array <String>)


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

def pieces
  simple? ? [self] : (parts + compound_pieces)
end