Sha256: a3c9b1769f62689b68e76e5cf8c865545ba84872d7acd1309e5dbe8c1221c14d
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
module Hanoi module Jane module Formatters class Github < Array attr_accessor :stacks def initialize towers @stacks = towers.stacks populate end def draw_disc disc, height = 0, offset = 0 if disc width = Hanoi::Jane.scale disc shim = (15 - width) / 2 (width).times do |i| self[6 - height][i + offset + shim] = 8 end end end def draw_stack stack, offset = 0 height = 0 stack.each do |disc| draw_disc disc, height, offset height += 1 end end def wipe 7.times do |i| self[i] = [0] * 52 end end def populate wipe draw_spindles draw_stacks end def draw_spindles self.map do |row| offset = 8 3.times do row[offset] = 1 offset += 16 end end end def draw_stacks offset = 1 @stacks.each do |stack| draw_stack stack, offset offset += 16 end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hanoi-jane-0.4.0 | lib/hanoi/jane/formatters/github.rb |