diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-08-14 00:02:25 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-08-13 15:02:29 +0000 |
commit | 3af5badae85851ba50e497c297b478cf88a6061a (patch) | |
tree | 5c7eb1d046851143b32451c910190d8a4a48a9f4 | |
parent | eb221a37349806bc202dbea2c088754c674605fc (diff) |
[ruby/irb] Remove useless `begin`/`end` [ci skip]
(https://github.com/ruby/irb/pull/680)
The `rescue` was removed at https://github.com/ruby/irb/commit/420e7d227011.
https://github.com/ruby/irb/commit/8fa688e9c0
-rw-r--r-- | lib/irb/input-method.rb | 98 |
1 files changed, 48 insertions, 50 deletions
diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb index b574a3fe1f..bd7d4fede4 100644 --- a/lib/irb/input-method.rb +++ b/lib/irb/input-method.rb @@ -159,66 +159,64 @@ module IRB end end - begin - class ReadlineInputMethod < StdioInputMethod - def self.initialize_readline - require "readline" - rescue LoadError - else - include ::Readline - end + class ReadlineInputMethod < StdioInputMethod + def self.initialize_readline + require "readline" + rescue LoadError + else + include ::Readline + end - include HistorySavingAbility + include HistorySavingAbility - # Creates a new input method object using Readline - def initialize - self.class.initialize_readline - if Readline.respond_to?(:encoding_system_needs) - IRB.__send__(:set_encoding, Readline.encoding_system_needs.name, override: false) - end + # Creates a new input method object using Readline + def initialize + self.class.initialize_readline + if Readline.respond_to?(:encoding_system_needs) + IRB.__send__(:set_encoding, Readline.encoding_system_needs.name, override: false) + end - super + super - @eof = false + @eof = false - if Readline.respond_to?("basic_word_break_characters=") - Readline.basic_word_break_characters = IRB::InputCompletor::BASIC_WORD_BREAK_CHARACTERS - end - Readline.completion_append_character = nil - Readline.completion_proc = IRB::InputCompletor::CompletionProc + if Readline.respond_to?("basic_word_break_characters=") + Readline.basic_word_break_characters = IRB::InputCompletor::BASIC_WORD_BREAK_CHARACTERS end + Readline.completion_append_character = nil + Readline.completion_proc = IRB::InputCompletor::CompletionProc + end - # Reads the next line from this input method. - # - # See IO#gets for more information. - def gets - Readline.input = @stdin - Readline.output = @stdout - if l = readline(@prompt, false) - HISTORY.push(l) if !l.empty? - @line[@line_no += 1] = l + "\n" - else - @eof = true - l - end + # Reads the next line from this input method. + # + # See IO#gets for more information. + def gets + Readline.input = @stdin + Readline.output = @stdout + if l = readline(@prompt, false) + HISTORY.push(l) if !l.empty? + @line[@line_no += 1] = l + "\n" + else + @eof = true + l end + end - # Whether the end of this input method has been reached, returns +true+ - # if there is no more data to read. - # - # See IO#eof? for more information. - def eof? - @eof - end + # Whether the end of this input method has been reached, returns +true+ + # if there is no more data to read. + # + # See IO#eof? for more information. + def eof? + @eof + end - # For debug message - def inspect - readline_impl = (defined?(Reline) && Readline == Reline) ? 'Reline' : 'ext/readline' - str = "ReadlineInputMethod with #{readline_impl} #{Readline::VERSION}" - inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc') - str += " and #{inputrc_path}" if File.exist?(inputrc_path) - str - end + # For debug message + def inspect + readline_impl = (defined?(Reline) && Readline == Reline) ? 'Reline' : 'ext/readline' + str = "ReadlineInputMethod with #{readline_impl} #{Readline::VERSION}" + inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc') + str += " and #{inputrc_path}" if File.exist?(inputrc_path) + str end end |