module Pangrid::AcrossLiteUtils

Public Instance Methods

empty_fill(xw) click to toggle source

{xw | solution = Cell[]} -> String

# File lib/pangrid/plugins/acrosslite.rb, line 63
def empty_fill(xw)
  # when converting from another format -> binary we won't typically have fill
  # information, since that is an internal property of the acrosslite player
  grid = xw.to_array(FILL_CHARS) {|c| '-'}
  grid.map(&:join).join
end
pack_solution(xw) click to toggle source

{xw | solution = Cell[]} -> String

# File lib/pangrid/plugins/acrosslite.rb, line 56
def pack_solution(xw)
  # acrosslite doesn't support non-rectangular grids, so map null squares to
  # black too
  xw.to_array(GRID_CHARS).map(&:join).join
end
unpack_solution(xw, s) click to toggle source

String -> Cell[]

# File lib/pangrid/plugins/acrosslite.rb, line 49
def unpack_solution(xw, s)
  s.each_char.map {|c|
    Cell.new(:solution => c == '.' ? :black : c)
  }.each_slice(xw.width).to_a
end