aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authormanga_osyo <manga.osyo@gmail.com>2022-10-10 12:30:35 +0900
committergit <svn-admin@ruby-lang.org>2022-10-14 21:31:24 +0900
commit7b7e5153e81288fe57ae64f2e1db228435156aeb (patch)
tree1a8b210186518f1e0ed41f220f75676273c7b277 /lib
parent5ccb625fbbd1e774636a9fdbe0bf1c3d38e085d5 (diff)
downloadruby-7b7e5153e81288fe57ae64f2e1db228435156aeb.tar.gz
[ruby/pp] [Feature #19045] Add support Data#pretty_print
https://github.com/ruby/pp/commit/343a20d721
Diffstat (limited to 'lib')
-rw-r--r--lib/pp.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/pp.rb b/lib/pp.rb
index f43356a3df..81551aa116 100644
--- a/lib/pp.rb
+++ b/lib/pp.rb
@@ -416,6 +416,26 @@ class Struct # :nodoc:
end
end
+class Data # :nodoc:
+ def pretty_print(q) # :nodoc:
+ q.group(1, sprintf("#<data %s", PP.mcall(self, Kernel, :class).name), '>') {
+ q.seplist(PP.mcall(self, Data, :members), lambda { q.text "," }) {|member|
+ q.breakable
+ q.text member.to_s
+ q.text '='
+ q.group(1) {
+ q.breakable ''
+ q.pp public_send(member)
+ }
+ }
+ }
+ end
+
+ def pretty_print_cycle(q) # :nodoc:
+ q.text sprintf("#<data %s:...>", PP.mcall(self, Kernel, :class).name)
+ end
+end if "3.2" <= RUBY_VERSION
+
class Range # :nodoc:
def pretty_print(q) # :nodoc:
q.pp self.begin