Module Buffering
In: openssl/lib/openssl/buffering.rb

Methods

<<   close   each   each_byte   each_line   eof   eof?   flush   getc   gets   new   print   printf   puts   read   readchar   readline   readlines   ungetc   write  

Included Modules

Enumerable

Constants

BLOCK_SIZE = 1024*16

Attributes

sync  [RW] 

Public Class methods

[Source]

# File openssl/lib/openssl/buffering.rb, line 22
  def initialize(*args)
    @sync = @io.sync
  end

Public Instance methods

[Source]

# File openssl/lib/openssl/buffering.rb, line 160
  def << (s)
    do_write(s)
    self
  end

[Source]

# File openssl/lib/openssl/buffering.rb, line 196
  def close
    flush rescue nil
    sysclose
  end

[Source]

# File openssl/lib/openssl/buffering.rb, line 86
  def each(eol=$/)
    while line = self.gets(eol?)
      yield line
    end
  end

[Source]

# File openssl/lib/openssl/buffering.rb, line 111
  def each_byte
    while c = getc
      yield(c)
    end
  end
each_line(eol=$/)

Alias for each

eof()

Alias for eof?

[Source]

# File openssl/lib/openssl/buffering.rb, line 126
  def eof?
    @eof ||= nil
    @eof && @rbuffer.size == 0
  end

[Source]

# File openssl/lib/openssl/buffering.rb, line 189
  def flush
    osync = @sync
    @sync = true
    do_write ""
    @sync = osync
  end

[Source]

# File openssl/lib/openssl/buffering.rb, line 106
  def getc
    c = read(1)
    c ? c.to_i : nil
  end

[Source]

# File openssl/lib/openssl/buffering.rb, line 69
  def gets(eol=$/)
    fill_rbuff unless defined? @rbuffer
    idx = @rbuffer.index(eol)
    @eof ||= nil
    until @eof
      break if idx
      fill_rbuff
      idx = @rbuffer.index(eol)
    end
    if eol.is_a?(Regexp)
      size = idx ? idx+$&.size : nil
    else
      size = idx ? idx+eol.size : nil
    end
    consume_rbuff(size)
  end

[Source]

# File openssl/lib/openssl/buffering.rb, line 177
  def print(*args)
    s = ""
    args.each{ |arg| s << arg.to_s }
    do_write(s)
    nil
  end

[Source]

# File openssl/lib/openssl/buffering.rb, line 184
  def printf(s, *args)
    do_write(s % args)
    nil
  end

[Source]

# File openssl/lib/openssl/buffering.rb, line 165
  def puts(*args)
    s = ""
    args.each{|arg|
      s << arg.to_s
      unless /#{$/}\z/o =~ s
        s << $/
      end
    }
    do_write(s)
    nil
  end

[Source]

# File openssl/lib/openssl/buffering.rb, line 54
  def read(size=nil, buf=nil)
    fill_rbuff unless defined? @rbuffer
    @eof ||= nil
    until @eof
      break if size && size <= @rbuffer.size
      fill_rbuff
    end
    ret = consume_rbuff(size) || ""
    if buf
      buf.replace(ret)
      ret = buf
    end
    (size && ret.empty?) ? nil : ret
  end

[Source]

# File openssl/lib/openssl/buffering.rb, line 117
  def readchar
    raise EOFErorr if eof?
    getc
  end

[Source]

# File openssl/lib/openssl/buffering.rb, line 101
  def readline(eol=$/)
    raise EOFErorr if eof?
    gets(eol)
  end

[Source]

# File openssl/lib/openssl/buffering.rb, line 93
  def readlines(eol=$/)
    ary = []
    while line = self.gets(eol)
      ary << line
    end
    ary
  end

[Source]

# File openssl/lib/openssl/buffering.rb, line 122
  def ungetc(c)
    @rbuffer[0,0] = c.chr
  end

[Source]

# File openssl/lib/openssl/buffering.rb, line 155
  def write(s)
    do_write(s)
    s.length
  end

[Validate]