Skip to content

Commit 153b1e9

Browse files
authored
Remove unused InputMethod#initialize (#635)
* Remove unused InputMethod#initialize The constructor takes a `file_name` argument, but it is never used. The only input method that needs a file is `FileInputMethod`, which has its own constructor to take a file object directly. So the constructor in `InputMethod` is not needed and its child classes don't need to call `super` in their constructors. * Remove unused FileInputMethod#file_name
1 parent bbd2044 commit 153b1e9

File tree

2 files changed

+0
-16
lines changed

2 files changed

+0
-16
lines changed

lib/irb/input-method.rb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,7 @@
99
require 'reline'
1010

1111
module IRB
12-
STDIN_FILE_NAME = "(line)" # :nodoc:
1312
class InputMethod
14-
15-
# Creates a new input method object
16-
def initialize(file = STDIN_FILE_NAME)
17-
@file_name = file
18-
end
19-
# The file name of this input method, usually given during initialization.
20-
attr_reader :file_name
21-
2213
# The irb prompt associated with this input method
2314
attr_accessor :prompt
2415

@@ -59,7 +50,6 @@ def inspect
5950
class StdioInputMethod < InputMethod
6051
# Creates a new input method object
6152
def initialize
62-
super
6353
@line_no = 0
6454
@line = []
6555
@stdin = IO.open(STDIN.to_i, :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
@@ -133,12 +123,9 @@ def open(file, &block)
133123

134124
# Creates a new input method object
135125
def initialize(file)
136-
super
137126
@io = file.is_a?(IO) ? file : File.open(file)
138127
@external_encoding = @io.external_encoding
139128
end
140-
# The file name of this input method, usually given during initialization.
141-
attr_reader :file_name
142129

143130
# Whether the end of this input method has been reached, returns +true+ if
144131
# there is no more data to read.
@@ -186,7 +173,6 @@ def initialize
186173
if Readline.respond_to?(:encoding_system_needs)
187174
IRB.__send__(:set_encoding, Readline.encoding_system_needs.name, override: false)
188175
end
189-
super
190176

191177
@line_no = 0
192178
@line = []
@@ -267,7 +253,6 @@ class RelineInputMethod < InputMethod
267253
# Creates a new input method object using Reline
268254
def initialize
269255
IRB.__send__(:set_encoding, Reline.encoding_system_needs.name, override: false)
270-
super
271256

272257
@line_no = 0
273258
@line = []

test/irb/helper.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class TestInputMethod < ::IRB::InputMethod
2222
attr_reader :list, :line_no
2323

2424
def initialize(list = [])
25-
super("test")
2625
@line_no = 0
2726
@list = list
2827
end

0 commit comments

Comments
 (0)