Sha256: 75682d09d4cdb435c2e4f9359c4ae4e102969742691fe1b9a3c37ae328e471bb
Contents?: true
Size: 1.42 KB
Versions: 335
Compression:
Stored size: 1.42 KB
Contents
local lookup = { [ ' _ ' .. '| |' .. '|_|' .. ' ' ] = '0', [ ' ' .. ' |' .. ' |' .. ' ' ] = '1', [ ' _ ' .. ' _|' .. '|_ ' .. ' ' ] = '2', [ ' _ ' .. ' _|' .. ' _|' .. ' ' ] = '3', [ ' ' .. '|_|' .. ' |' .. ' ' ] = '4', [ ' _ ' .. '|_ ' .. ' _|' .. ' ' ] = '5', [ ' _ ' .. '|_ ' .. '|_|' .. ' ' ] = '6', [ ' _ ' .. ' |' .. ' |' .. ' ' ] = '7', [ ' _ ' .. '|_|' .. '|_|' .. ' ' ] = '8', [ ' _ ' .. '|_|' .. ' _|' .. ' ' ] = '9', } local row_pattern = ('[^\n]+\n'):rep(4) .. '*' local function lines(s) local lines = {} for line in s:gmatch('[^\n]+') do assert(#line % 3 == 0) table.insert(lines, line) end return lines end local function parse(row) local result = '' local lines = lines(row) assert(#lines[1] == #lines[2] and #lines[2] == #lines[3] and #lines[3] == #lines[4]) for i = 1, #lines[1], 3 do local character = '' for line = 1, 4 do character = character .. lines[line]:sub(i, i + 2) end result = result .. (lookup[character] or '?') end return result end return { convert = function(s) local results = {} for row in s:gmatch(row_pattern) do table.insert(results, parse(row)) end return table.concat(results, ',') end }
Version data entries
335 entries across 335 versions & 1 rubygems