[ruby/irb] Remove unused InputMethod#initialize
(https://github.com/ruby/irb/pull/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 https://github.com/ruby/irb/commit/153b1e9d1c
This commit is contained in:
parent
589c01c411
commit
0387b86c3a
@ -9,16 +9,7 @@ require 'io/console'
|
|||||||
require 'reline'
|
require 'reline'
|
||||||
|
|
||||||
module IRB
|
module IRB
|
||||||
STDIN_FILE_NAME = "(line)" # :nodoc:
|
|
||||||
class InputMethod
|
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
|
# The irb prompt associated with this input method
|
||||||
attr_accessor :prompt
|
attr_accessor :prompt
|
||||||
|
|
||||||
@ -59,7 +50,6 @@ module IRB
|
|||||||
class StdioInputMethod < InputMethod
|
class StdioInputMethod < InputMethod
|
||||||
# Creates a new input method object
|
# Creates a new input method object
|
||||||
def initialize
|
def initialize
|
||||||
super
|
|
||||||
@line_no = 0
|
@line_no = 0
|
||||||
@line = []
|
@line = []
|
||||||
@stdin = IO.open(STDIN.to_i, :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
|
@stdin = IO.open(STDIN.to_i, :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
|
||||||
@ -133,12 +123,9 @@ module IRB
|
|||||||
|
|
||||||
# Creates a new input method object
|
# Creates a new input method object
|
||||||
def initialize(file)
|
def initialize(file)
|
||||||
super
|
|
||||||
@io = file.is_a?(IO) ? file : File.open(file)
|
@io = file.is_a?(IO) ? file : File.open(file)
|
||||||
@external_encoding = @io.external_encoding
|
@external_encoding = @io.external_encoding
|
||||||
end
|
end
|
||||||
# The file name of this input method, usually given during initialization.
|
|
||||||
attr_reader :file_name
|
|
||||||
|
|
||||||
# Whether the end of this input method has been reached, returns +true+ if
|
# Whether the end of this input method has been reached, returns +true+ if
|
||||||
# there is no more data to read.
|
# there is no more data to read.
|
||||||
@ -186,7 +173,6 @@ module IRB
|
|||||||
if Readline.respond_to?(:encoding_system_needs)
|
if Readline.respond_to?(:encoding_system_needs)
|
||||||
IRB.__send__(:set_encoding, Readline.encoding_system_needs.name, override: false)
|
IRB.__send__(:set_encoding, Readline.encoding_system_needs.name, override: false)
|
||||||
end
|
end
|
||||||
super
|
|
||||||
|
|
||||||
@line_no = 0
|
@line_no = 0
|
||||||
@line = []
|
@line = []
|
||||||
@ -267,7 +253,6 @@ module IRB
|
|||||||
# Creates a new input method object using Reline
|
# Creates a new input method object using Reline
|
||||||
def initialize
|
def initialize
|
||||||
IRB.__send__(:set_encoding, Reline.encoding_system_needs.name, override: false)
|
IRB.__send__(:set_encoding, Reline.encoding_system_needs.name, override: false)
|
||||||
super
|
|
||||||
|
|
||||||
@line_no = 0
|
@line_no = 0
|
||||||
@line = []
|
@line = []
|
||||||
|
@ -22,7 +22,6 @@ module TestIRB
|
|||||||
attr_reader :list, :line_no
|
attr_reader :list, :line_no
|
||||||
|
|
||||||
def initialize(list = [])
|
def initialize(list = [])
|
||||||
super("test")
|
|
||||||
@line_no = 0
|
@line_no = 0
|
||||||
@list = list
|
@list = list
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user