From 524a808d23f1ed3eca946236e98e049b55458e71 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 2 Dec 2021 18:29:45 +0900 Subject: [PATCH] Define Ripper::Lexer::Elem#to_s Alias `#inspect` as `#to_s` also in the new `Ripper::Lexer::Elem` class, so that `puts Ripper::Lexer.new(code).scan` shows the attributes. --- ext/ripper/lib/ripper/lexer.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext/ripper/lib/ripper/lexer.rb b/ext/ripper/lib/ripper/lexer.rb index 23db3a0570..cc1f74f1e3 100644 --- a/ext/ripper/lib/ripper/lexer.rb +++ b/ext/ripper/lib/ripper/lexer.rb @@ -119,6 +119,8 @@ class Ripper "#<#{self.class}: #{event}@#{pos[0]}:#{pos[1]}:#{state}: #{tok.inspect}#{": " if message}#{message}>" end + alias to_s inspect + def pretty_print(q) q.group(2, "#<#{self.class}:", ">") { q.breakable