class CTI::Builder::Fragment

Public Instance Methods

flush(tempFile, out) click to toggle source

フラグメントの内容を吐き出して、フラグメントを破棄します。

tempFile

一時ファイル

out

出力先ストリーム( IO )

# File CTI/Builder/StreamBuilder.rb, line 74
def flush(tempFile, out)
  unless @segments
    out.write(@buffer)
    @buffer = nil
  else
    segcount = @segments.size
    for seg in @segments
      tempFile.pos = seg * CTIP2::SEGMENT_SIZE
      buff = tempFile.read(seg == @segments.last ? @segLen : CTIP2::SEGMENT_SIZE)
      out.write(buff)
    end
  end
end
id() click to toggle source
# File CTI/Builder/StreamBuilder.rb, line 17
def id
  @id
end
nxt() click to toggle source
# File CTI/Builder/StreamBuilder.rb, line 33
def nxt
  @nxt
end
nxt=(nxt) click to toggle source
# File CTI/Builder/StreamBuilder.rb, line 29
def nxt=(nxt)
  @nxt = nxt
end
prev() click to toggle source
# File CTI/Builder/StreamBuilder.rb, line 25
def prev
  @prev
end
prev=(prev) click to toggle source
# File CTI/Builder/StreamBuilder.rb, line 21
def prev=(prev)
  @prev = prev
end
write(tempFile, onMemory, segment, bytes) click to toggle source

フラグメントにデータを書き込みます。

tempFile

一時ファイル

onMemory

メモリ上に置かれたデータの合計サイズ

segment

セグメント番号シーケンス

bytes

データ

戻り値

書き込んだバイト数

# File CTI/Builder/StreamBuilder.rb, line 48
def write(tempFile, onMemory, segment, bytes)
  len = bytes.bytesize
  if (!@segments &&
  @length + len <= CTIP2::FRG_MEM_SIZE &&
  onMemory + len <= CTIP2::ON_MEMORY)
    @buffer += bytes
    onMemory += len
  else
    if @buffer
      segment, wlen = raf_write(tempFile, segment, @buffer)
      onMemory -= wlen
      @buffer = nil
    end
    segment, len = raf_write(tempFile, segment, bytes)
  end
  @length += len
  return onMemory, segment, len
end

Public Class Methods

new(id) click to toggle source
# File CTI/Builder/StreamBuilder.rb, line 9
def initialize(id)
  @id = id
  @prev = nil
  @nxt = nil
  @length = 0
  @buffer = ''
end