26 lines
356 B
Plaintext
26 lines
356 B
Plaintext
class Buffer
|
|
new: (limit = 5) =>
|
|
@limit = limit
|
|
@data = {}
|
|
|
|
purge: =>
|
|
if #@data > @limit
|
|
table.remove @data, 1
|
|
@purge!
|
|
else return
|
|
|
|
add: (line) =>
|
|
table.insert @data, line
|
|
@purge!
|
|
|
|
with Buffer 5
|
|
while true
|
|
n = io.read!
|
|
if n ~= nil
|
|
\add n
|
|
else
|
|
break
|
|
|
|
for _, i in pairs .data
|
|
print i
|