class Hanoi::Jane::Formatters::Github
Attributes
stacks[RW]
Public Class Methods
new(towers)
click to toggle source
# File lib/hanoi/jane/formatters/github.rb, line 7 def initialize towers @stacks = towers.stacks populate end
Public Instance Methods
draw_disc(disc, height = 0, offset = 0)
click to toggle source
# File lib/hanoi/jane/formatters/github.rb, line 13 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
draw_spindles()
click to toggle source
# File lib/hanoi/jane/formatters/github.rb, line 43 def draw_spindles self.map do |row| offset = 8 3.times do row[offset] = 1 offset += 16 end end end
draw_stack(stack, offset = 0)
click to toggle source
# File lib/hanoi/jane/formatters/github.rb, line 23 def draw_stack stack, offset = 0 height = 0 stack.each do |disc| draw_disc disc, height, offset height += 1 end end
draw_stacks()
click to toggle source
# File lib/hanoi/jane/formatters/github.rb, line 53 def draw_stacks offset = 1 @stacks.each do |stack| draw_stack stack, offset offset += 16 end end
populate()
click to toggle source
# File lib/hanoi/jane/formatters/github.rb, line 37 def populate wipe draw_spindles draw_stacks end
wipe()
click to toggle source
# File lib/hanoi/jane/formatters/github.rb, line 31 def wipe 7.times do |i| self[i] = [0] * 52 end end