Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
OpenSSL::Buffering#gets
(?::String | ::Regexp eol, ?::Integer limit, ?chomp: ::boolish) -> ::String?
gets(eol=$/, limit=nil, chomp: false)
ext/openssl/lib/openssl/buffering.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.4.1/ext/openssl/lib/openssl/buffering.rb, line 238
def gets(eol=$/, limit=nil, chomp: false)
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
if size && limit && limit >= 0
size = [size, limit].min
end
line = consume_rbuff(size)
if chomp && line
line.chomp!(eol)
end
line
end
Reads the next “line” from the stream. Lines are separated by eol. If limit is provided the result will not be longer than the given number of bytes.
eol may be a String or Regexp.
Unlike IO#gets the line read will not be assigned to +$_+.
Unlike IO#gets the separator must be provided if a limit is provided.