1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

make sync-default-gems GEM=irb

from e8e79d569e.

This colorizes Range object on IRB inspect.
This commit is contained in:
Takashi Kokubun 2019-04-28 21:51:35 +09:00
parent 13abf5519a
commit f2d7ba6a74
No known key found for this signature in database
GPG key ID: 6FFC433B12EE23DD
2 changed files with 7 additions and 6 deletions

View file

@ -47,17 +47,17 @@ module IRB # :nodoc:
end
def inspect_colorable?(obj)
if obj.is_a?(Module) && obj.name
return true
end
case obj
when String, Symbol, Regexp, Integer, Float, FalseClass, TrueClass, NilClass
true
when Hash
obj.all? { |k, v| inspect_colorable?(k) && inspect_colorable?(v) }
when Array
obj.all? { |o| inspect_colorable?(o) }
when String, Symbol, Regexp, Integer, Float, FalseClass, TrueClass, NilClass
true
when Range
inspect_colorable?(obj.begin) && inspect_colorable?(obj.end)
when Module
!obj.name.nil?
else
false
end

View file

@ -44,6 +44,7 @@ module TestIRB
['foo', :bar] => true,
{ a: 4 } => true,
/reg/ => true,
(1..3) => true,
Object.new => false,
Struct => true,
Test => true,