Skip to content

Commit 0a0409c

Browse files
authored
Simplify irb_info command (#597)
1 parent 3951757 commit 0a0409c

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

lib/irb/cmd/irb_info.rb

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,20 @@ class IrbInfo < Nop
1111
description "Show information about IRB."
1212

1313
def execute
14-
Class.new {
15-
def inspect
16-
str = "Ruby version: #{RUBY_VERSION}\n"
17-
str += "IRB version: #{IRB.version}\n"
18-
str += "InputMethod: #{IRB.CurrentContext.io.inspect}\n"
19-
str += ".irbrc path: #{IRB.rc_file}\n" if File.exist?(IRB.rc_file)
20-
str += "RUBY_PLATFORM: #{RUBY_PLATFORM}\n"
21-
str += "LANG env: #{ENV["LANG"]}\n" if ENV["LANG"] && !ENV["LANG"].empty?
22-
str += "LC_ALL env: #{ENV["LC_ALL"]}\n" if ENV["LC_ALL"] && !ENV["LC_ALL"].empty?
23-
str += "East Asian Ambiguous Width: #{Reline.ambiguous_width.inspect}\n"
24-
if RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
25-
codepage = `chcp`.b.sub(/.*: (\d+)\n/, '\1')
26-
str += "Code page: #{codepage}\n"
27-
end
28-
str
29-
end
30-
alias_method :to_s, :inspect
31-
}.new
14+
str = "Ruby version: #{RUBY_VERSION}\n"
15+
str += "IRB version: #{IRB.version}\n"
16+
str += "InputMethod: #{IRB.CurrentContext.io.inspect}\n"
17+
str += ".irbrc path: #{IRB.rc_file}\n" if File.exist?(IRB.rc_file)
18+
str += "RUBY_PLATFORM: #{RUBY_PLATFORM}\n"
19+
str += "LANG env: #{ENV["LANG"]}\n" if ENV["LANG"] && !ENV["LANG"].empty?
20+
str += "LC_ALL env: #{ENV["LC_ALL"]}\n" if ENV["LC_ALL"] && !ENV["LC_ALL"].empty?
21+
str += "East Asian Ambiguous Width: #{Reline.ambiguous_width.inspect}\n"
22+
if RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
23+
codepage = `chcp`.b.sub(/.*: (\d+)\n/, '\1')
24+
str += "Code page: #{codepage}\n"
25+
end
26+
puts str
27+
nil
3228
end
3329
end
3430
end

0 commit comments

Comments
 (0)