diff options
author | manga_osyo <manga.osyo@gmail.com> | 2022-10-10 12:30:35 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-10-14 21:31:24 +0900 |
commit | 7b7e5153e81288fe57ae64f2e1db228435156aeb (patch) | |
tree | 1a8b210186518f1e0ed41f220f75676273c7b277 /lib | |
parent | 5ccb625fbbd1e774636a9fdbe0bf1c3d38e085d5 (diff) | |
download | ruby-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.rb | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -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 |