mirror of
https://github.com/Myzel394/easytables.nvim.git
synced 2025-06-18 14:55:26 +02:00
47 lines
765 B
Lua
47 lines
765 B
Lua
local M = {};
|
|
|
|
function M:create(cols, rows)
|
|
local table = {}
|
|
for i = 1, rows do
|
|
table[i] = {}
|
|
for j = 1, cols do
|
|
table[i][j] = ""
|
|
end
|
|
end
|
|
|
|
self.table = table
|
|
|
|
return self
|
|
end
|
|
|
|
function M:insert(row, col, value)
|
|
self.table[row][col] = value
|
|
end
|
|
|
|
function M:value_at(row, col)
|
|
return self.table[row][col]
|
|
end
|
|
|
|
function M:get_largest_length()
|
|
local largest = #self.table[1][1]
|
|
for _, row in ipairs(self.table) do
|
|
for _, col in ipairs(row) do
|
|
if #col > largest then
|
|
largest = #col
|
|
end
|
|
end
|
|
end
|
|
|
|
return largest
|
|
end
|
|
|
|
function M:rows_amount()
|
|
return #self.table
|
|
end
|
|
|
|
function M:cols_amount()
|
|
return #self.table[1]
|
|
end
|
|
|
|
return M
|