a simple buffer of contiguous data
# File lib/sup/mbox/ssh-file.rb, line 54 def [](o) raise "only ranges supported due to programmer's laziness" unless o.is_a? Range @buf[Range.new(o.first - @start, o.last - @start, o.exclude_end?)] end
# File lib/sup/mbox/ssh-file.rb, line 34 def add data, offset=endd #MBox::debug "+ adding #{data.length} bytes; size will be #{size + data.length}; limit #{SSHFile::MAX_BUF_SIZE}" if start.nil? @buf = data @start = offset return end raise "non-continguous data added to buffer (data #{offset}:#{offset + data.length}, buf range #{start}:#{endd})" if offset + data.length < start || offset > endd if offset < start @buf = data[0 ... (start - offset)] + @buf @start = offset else return if offset + data.length < endd @buf += data[(endd - offset) .. -1] end end
# File lib/sup/mbox/ssh-file.rb, line 25 def clear! @start = nil @buf = "" end
# File lib/sup/mbox/ssh-file.rb, line 30 def empty?; @start.nil?; end
# File lib/sup/mbox/ssh-file.rb, line 32 def endd; @start + @buf.length; end
# File lib/sup/mbox/ssh-file.rb, line 59 def index what, start=0 x = @buf.index(what, start - @start) x.nil? ? nil : x + @start end
# File lib/sup/mbox/ssh-file.rb, line 64 def rindex what, start=0 x = @buf.rindex(what, start - @start) x.nil? ? nil : x + @start end
Generated with the Darkfish Rdoc Generator 2.