123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
# File 'lib/gamemaker/card_game/playing_card.rb', line 123
def to_s(format = :simple, seperator: ' ', seperators: nil)
if format != :fancy && seperators
raise ArgumentError, "Invalid option `seperators: #{seperators.inspect}` (did you mean `seperator`?)"
end
strings = @cards.map { |c| c.to_s(format) }
if format == :fancy
seperators ||= [' ' * seperator.length, ' ' * seperator.length, seperator]
strings.map(&:split)
.transpose
.zip(seperators)
.map { |line| line.inject(:join) }
.join("\n") + "\n"
else
strings.join(seperator)
end
end
|