Skip to content

Commit

Permalink
Add support for gets(chomp: true).
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jan 1, 2024
1 parent 69b596b commit 42e8240
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/openssl/buffering.rb
Expand Up @@ -229,7 +229,7 @@ def read_nonblock(maxlen, buf=nil, exception: true)
#
# Unlike IO#gets the separator must be provided if a limit is provided.

def gets(eol=$/, limit=nil)
def gets(eol=$/, limit=nil, chomp: false)
idx = @rbuffer.index(eol)
until @eof
break if idx
Expand All @@ -244,7 +244,11 @@ def gets(eol=$/, limit=nil)
if size && limit && limit >= 0
size = [size, limit].min
end
consume_rbuff(size)
line = consume_rbuff(size)
if chomp && line
line.chomp!(eol)
end
line
end

##
Expand Down

0 comments on commit 42e8240

Please sign in to comment.