1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
# frozen_string_literal: true
module Unparser
module Writer
# Writer for rescue bodies
class Resbody
include Writer
children :exception, :assignment, :body
def emit_postcontrol
write(' rescue ')
visit(body)
end
def emit_regular
write('rescue')
emit_exception
emit_assignment
emit_optional_body(body)
end
private
def emit_exception
return unless exception
ws
delimited(exception.children)
end
def emit_assignment
return unless assignment
write(' => ')
visit(assignment)
end
end # Resbody
end # Writer
end # Unparser
|