mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 08:33:58 +02:00
* lib/time.rb (Time.rfc2822, Time#rfc2822): preserve localtimeness.
* lib/pp.rb: pretty_print_cycled is renamed to pretty_print_cycle. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4b0f91401c
commit
9c4a482229
3 changed files with 47 additions and 12 deletions
18
lib/pp.rb
18
lib/pp.rb
|
@ -83,9 +83,9 @@ PP#pp to print the object.
|
|||
== methods
|
||||
--- pp(obj)
|
||||
adds ((|obj|)) to the pretty printing buffer
|
||||
using Object#pretty_print or Object#pretty_print_cycled.
|
||||
using Object#pretty_print or Object#pretty_print_cycle.
|
||||
|
||||
Object#pretty_print_cycled is used when ((|obj|)) is already
|
||||
Object#pretty_print_cycle is used when ((|obj|)) is already
|
||||
printed, a.k.a the object reference chain has a cycle.
|
||||
|
||||
--- object_group(obj) { ... }
|
||||
|
@ -111,7 +111,7 @@ PP#pp to print the object.
|
|||
This module provides predefined pretty_print() methods for some of
|
||||
the most commonly used built-in classes for convenience.
|
||||
|
||||
--- pretty_print_cycled(pp)
|
||||
--- pretty_print_cycle(pp)
|
||||
is a default pretty printing method for general objects that are
|
||||
detected as part of a cycle.
|
||||
|
||||
|
@ -179,7 +179,7 @@ class PP < PrettyPrint
|
|||
id = obj.__id__
|
||||
|
||||
if Thread.current[InspectKey].include? id
|
||||
group {obj.pretty_print_cycled self}
|
||||
group {obj.pretty_print_cycle self}
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -273,7 +273,7 @@ class PP < PrettyPrint
|
|||
end
|
||||
end
|
||||
|
||||
def pretty_print_cycled(pp)
|
||||
def pretty_print_cycle(pp)
|
||||
pp.object_address_group(self) {
|
||||
pp.breakable
|
||||
pp.text '...'
|
||||
|
@ -304,7 +304,7 @@ class Array
|
|||
}
|
||||
end
|
||||
|
||||
def pretty_print_cycled(pp)
|
||||
def pretty_print_cycle(pp)
|
||||
pp.text(empty? ? '[]' : '[...]')
|
||||
end
|
||||
end
|
||||
|
@ -314,7 +314,7 @@ class Hash
|
|||
pp.pp_hash self
|
||||
end
|
||||
|
||||
def pretty_print_cycled(pp)
|
||||
def pretty_print_cycle(pp)
|
||||
pp.text(empty? ? '{}' : '{...}')
|
||||
end
|
||||
end
|
||||
|
@ -341,7 +341,7 @@ class Struct
|
|||
}
|
||||
end
|
||||
|
||||
def pretty_print_cycled(pp)
|
||||
def pretty_print_cycle(pp)
|
||||
pp.text sprintf("#<%s:...>", self.class.name)
|
||||
end
|
||||
end
|
||||
|
@ -440,7 +440,7 @@ end
|
|||
|
||||
[Numeric, Symbol, FalseClass, TrueClass, NilClass, Module].each {|c|
|
||||
c.class_eval {
|
||||
alias :pretty_print_cycled :pretty_print
|
||||
alias :pretty_print_cycle :pretty_print
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue