Skip to content

Commit

Permalink
Extract dedicated Symbol emitter
Browse files Browse the repository at this point in the history
  • Loading branch information
prikha committed Jan 18, 2024
1 parent 73d94bd commit 4a0ac3e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/unparser/emitter/primitive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,31 @@ class Primitive < self
# Emitter for primitives based on Object#inspect
class Inspect < self

handle :sym, :str
handle :str

private

def dispatch
if RUBY_VERSION < '3.2' && node.type == :sym && value[-1] == '='
write(value.inspect)
end

end # Inspect

class Symbol < self

handle :sym

private

def dispatch
if RUBY_VERSION < '3.2' && value[-1] == '='
write(":#{value.name.inspect}")
else
write(value.inspect)
end
end

end # Inspect
end # Symbol

# Emitter for complex literals
class Complex < self
Expand Down

0 comments on commit 4a0ac3e

Please sign in to comment.