summaryrefslogtreecommitdiff
path: root/ext/ripper
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-12-02 18:29:45 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-12-02 18:29:45 +0900
commit524a808d23f1ed3eca946236e98e049b55458e71 (patch)
treebab60c102b936d1a49b58d40740b023e12e2be05 /ext/ripper
parent39f2b4f1a4a0075c08ce9575a51ccea48c85f024 (diff)
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.
Diffstat (limited to 'ext/ripper')
-rw-r--r--ext/ripper/lib/ripper/lexer.rb2
1 files changed, 2 insertions, 0 deletions
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