Sha256: 7ec730740339e5052ccb04a854a1a9243bfac8b3bafe2980c0588b1d2016c1bc

Contents?: true

Size: 731 Bytes

Versions: 5

Compression:

Stored size: 731 Bytes

Contents

# frozen_string_literal: true

module Unparser
  module Writer
    class Rescue
      include Writer, Adamantium::Flat

      children :body, :rescue_body

      define_group :rescue_bodies, 1..-2

      def emit_regular
        emit_optional_body(body)

        rescue_bodies.each(&method(:emit_rescue_body))

        if else_node
          write('else')
          emit_body(else_node)
        end
      end

      def emit_postcontrol
        visit(body)
        writer_with(Resbody, rescue_body).emit_postcontrol
      end

    private

      def else_node
        children.last
      end

      def emit_rescue_body(node)
        writer_with(Resbody, node).emit_regular
      end
    end # Rescue
  end # Writer
end # Unparser

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
unparser-0.5.4 lib/unparser/writer/rescue.rb
unparser-0.5.3 lib/unparser/writer/rescue.rb
unparser-0.5.2 lib/unparser/writer/rescue.rb
unparser-0.5.1 lib/unparser/writer/rescue.rb
unparser-0.5.0 lib/unparser/writer/rescue.rb