| Module | Buffering |
| In: |
openssl/lib/openssl/buffering.rb
|
| BLOCK_SIZE | = | 1024*16 |
| sync | [RW] |
# File openssl/lib/openssl/buffering.rb, line 22 def initialize(*args) @eof = false @rbuffer = "" @sync = @io.sync end
# File openssl/lib/openssl/buffering.rb, line 117 def each(eol=$/) while line = self.gets(eol) yield line end end
# File openssl/lib/openssl/buffering.rb, line 157 def eof? fill_rbuff if !@eof && @rbuffer.empty? @eof && @rbuffer.empty? end
# File openssl/lib/openssl/buffering.rb, line 228 def flush osync = @sync @sync = true do_write "" @sync = osync end
# File openssl/lib/openssl/buffering.rb, line 102 def gets(eol=$/) idx = @rbuffer.index(eol) 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
# File openssl/lib/openssl/buffering.rb, line 216 def print(*args) s = "" args.each{ |arg| s << arg.to_s } do_write(s) nil end
# File openssl/lib/openssl/buffering.rb, line 201 def puts(*args) s = "" if args.empty? s << "\n" end args.each{|arg| s << arg.to_s if $/ && /\n\z/ !~ s s << "\n" end } do_write(s) nil end
# File openssl/lib/openssl/buffering.rb, line 56 def read(size=nil, buf=nil) if size == 0 if buf buf.clear else buf = "" end return @eof ? nil : buf end 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
# File openssl/lib/openssl/buffering.rb, line 132 def readline(eol=$/) raise EOFError if eof? gets(eol) end
# File openssl/lib/openssl/buffering.rb, line 124 def readlines(eol=$/) ary = [] while line = self.gets(eol) ary << line end ary end
# File openssl/lib/openssl/buffering.rb, line 77 def readpartial(maxlen, buf=nil) if maxlen == 0 if buf buf.clear else buf = "" end return @eof ? nil : buf end if @rbuffer.empty? begin return sysread(maxlen, buf) rescue Errno::EAGAIN retry end end ret = consume_rbuff(maxlen) if buf buf.replace(ret) ret = buf end raise EOFError if ret.empty? ret end
ruby-doc.org is hosted and maintained by James Britt and Happy Camper Studios, a Ruby application development company in Phoenix, Arizona. The site was created in 2002 as part of the Ruby Documentation Project to promote the Ruby language and to help other Ruby hackers.
Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.
For more information on the Ruby programming language, visit ruby-lang.org.
Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.