module ASCIICards
Constants
- RANK_SYMBOLS
- SUIT_SYMBOLS
- VERSION
Public Class Methods
stringify(*cards)
click to toggle source
# File lib/ascii_cards.rb, line 31 def stringify(*cards) join_cards( cards.map do |rank, suit, state = :visible| if state == :hidden hidden_card else format_card(rank, suit) end end ) end
Private Class Methods
format_card(rank, suit)
click to toggle source
# File lib/ascii_cards.rb, line 55 def format_card(rank, suit) rank_symbol = RANK_SYMBOLS.fetch(rank) suit_symbol = SUIT_SYMBOLS.fetch(suit) format(<<~ASCII, rank_symbol.ljust(2), suit_symbol, rank_symbol) ┌─────────┐ │%2s │ │ │ │ │ │ %s │ │ │ │ │ │ %2s│ └─────────┘ ASCII end
join_cards(cards)
click to toggle source
# File lib/ascii_cards.rb, line 45 def join_cards(cards) first, *rest = cards.map do |card| card.split("\n") end first.zip(*rest).map do |lines| lines.join('') end.join("\n") end