Skip to content

Commit 7b323ee

Browse files
authored
Refactor IRB::Context#prompting (#889)
1 parent f6d4896 commit 7b323ee

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

lib/irb/context.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,7 @@ def verbose?
479479
# StdioInputMethod or RelineInputMethod or ReadlineInputMethod, see #io
480480
# for more information.
481481
def prompting?
482-
verbose? || (STDIN.tty? && @io.kind_of?(StdioInputMethod) ||
483-
@io.kind_of?(RelineInputMethod) ||
484-
(defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)))
482+
verbose? || @io.prompting?
485483
end
486484

487485
# The return value of the last statement evaluated.

lib/irb/input-method.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ def support_history_saving?
4444
false
4545
end
4646

47+
def prompting?
48+
false
49+
end
50+
4751
# For debug message
4852
def inspect
4953
'Abstract InputMethod'
@@ -91,6 +95,10 @@ def readable_after_eof?
9195
true
9296
end
9397

98+
def prompting?
99+
STDIN.tty?
100+
end
101+
94102
# Returns the current line number for #io.
95103
#
96104
# #line counts the number of times #gets is called.
@@ -220,6 +228,10 @@ def eof?
220228
@eof
221229
end
222230

231+
def prompting?
232+
true
233+
end
234+
223235
# For debug message
224236
def inspect
225237
readline_impl = (defined?(Reline) && Readline == Reline) ? 'Reline' : 'ext/readline'
@@ -467,6 +479,10 @@ def eof?
467479
@eof
468480
end
469481

482+
def prompting?
483+
true
484+
end
485+
470486
# For debug message
471487
def inspect
472488
config = Reline::Config.new

0 commit comments

Comments
 (0)