Sha256: 8ac9a75d7bdc4ff3dac881ad0cdccfa00489e87db54244ecf14b702b0c87a8a5
Contents?: true
Size: 1.29 KB
Versions: 61
Compression:
Stored size: 1.29 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 table.insert(lines, line) end return lines end local function parse(row) local result = '' local lines = lines(row) 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
61 entries across 61 versions & 1 rubygems