class Buffer def initialize(bufname,contents) @bufname = bufname @contents = contents end def setbufer(contents) @buffer = contents end def putsbuffer() puts @contents end def putsarray() # An exception really should be raised #if $contents.class == Array @contents.each_with_index { |elem,i| puts "#{(i+1)} #{elem}" } # else puts "WWERROR: $contents is not an array." #end end def fillbuffer(startline, endline, contents) @contents = contents[startline..endline] end def appendcontents(contents) filebuffer = File.readlines($path) $contents.concat(filebuffer) end def addline(contents) @contents.push(contents) end def changeline(line,contents) @contents[line] = contents end def insertline(line, contents) @contents.insert(line, contents) end def printline(line) puts @contents[line] end def printrange(startline, endline) puts @contents[startline..endline] end def strikeline(line) @contents.delete_at(line) end def strikerange(startline, endline) @contents.slice!(startline..endline) end def addrange(contents) @contents.concat(contents) end def insertrange(line, contents) @contents.insert(line, contents) end end