Skip to content

Commit

Permalink
Remove unused InputMethod#initialize
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
st0012 committed Jul 8, 2023
1 parent 5e87f3b commit 01f615a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 14 deletions.
13 changes: 0 additions & 13 deletions lib/irb/input-method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,7 @@
require 'reline'

module IRB
STDIN_FILE_NAME = "(line)" # :nodoc:
class InputMethod

# Creates a new input method object
def initialize(file = STDIN_FILE_NAME)
@file_name = file
end
# The file name of this input method, usually given during initialization.
attr_reader :file_name

# The irb prompt associated with this input method
attr_accessor :prompt

Expand Down Expand Up @@ -56,7 +47,6 @@ def inspect
class StdioInputMethod < InputMethod
# Creates a new input method object
def initialize
super
@line_no = 0
@line = []
@stdin = IO.open(STDIN.to_i, :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
Expand Down Expand Up @@ -130,7 +120,6 @@ def open(file, &block)

# Creates a new input method object
def initialize(file)
super
@io = file.is_a?(IO) ? file : File.open(file)
@external_encoding = @io.external_encoding
end
Expand Down Expand Up @@ -183,7 +172,6 @@ def initialize
if Readline.respond_to?(:encoding_system_needs)
IRB.__send__(:set_encoding, Readline.encoding_system_needs.name, override: false)
end
super

@line_no = 0
@line = []
Expand Down Expand Up @@ -261,7 +249,6 @@ class RelineInputMethod < InputMethod
# Creates a new input method object using Reline
def initialize
IRB.__send__(:set_encoding, Reline.encoding_system_needs.name, override: false)
super

@line_no = 0
@line = []
Expand Down
1 change: 0 additions & 1 deletion test/irb/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class TestInputMethod < ::IRB::InputMethod
attr_reader :list, :line_no

def initialize(list = [])
super("test")
@line_no = 0
@list = list
end
Expand Down

0 comments on commit 01f615a

Please sign in to comment.