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:
parent
13abf5519a
commit
f2d7ba6a74
2 changed files with 7 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -44,6 +44,7 @@ module TestIRB
|
|||
['foo', :bar] => true,
|
||||
{ a: 4 } => true,
|
||||
/reg/ => true,
|
||||
(1..3) => true,
|
||||
Object.new => false,
|
||||
Struct => true,
|
||||
Test => true,
|
||||
|
|
Loading…
Add table
Reference in a new issue