Skip to content

Commit

Permalink
Kernel#gets and ARGF#gets *also* accept chomp: true
Browse files Browse the repository at this point in the history
  • Loading branch information
ParadoxV5 committed Dec 28, 2024
1 parent b147cbb commit b13c376
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/kernel.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@ module Kernel : BasicObject
# The style of programming using `$_` as an implicit parameter is gradually
# losing favor in the Ruby community.
#
def self?.gets: (?String arg0, ?Integer arg1) -> String?
def self?.gets: (?String sep, ?Integer limit, ?chomp: boolish) -> String?

# <!--
# rdoc-file=eval.c
Expand Down
2 changes: 1 addition & 1 deletion core/rbs/unnamed/argf.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ module RBS
# See IO.readlines for details about getline_args.
#
%a{annotate:rdoc:copy:ARGF#gets}
def gets: (?String sep, ?Integer limit) -> String?
def gets: (?String sep, ?Integer limit, ?chomp: boolish) -> String?

# <!--
# rdoc-file=io.c
Expand Down
4 changes: 4 additions & 0 deletions test/stdlib/ARGF_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def test_gets
ARGF.class.new(__FILE__), :gets, "\n"
assert_send_type "(::String sep, ::Integer limit) -> ::String",
ARGF.class.new(__FILE__), :gets, "\n", 1
assert_send_type "(chomp: boolish) -> ::String",
ARGF.class.new(__FILE__), :gets, chomp: true
assert_send_type "(::String sep, ::Integer limit, chomp: boolish) -> ::String",
ARGF.class.new(__FILE__), :gets, "\n", 1, chomp: true
assert_send_type "() -> nil",
ARGF.class.new(Tempfile.new), :gets
end
Expand Down

0 comments on commit b13c376

Please sign in to comment.