Sha256: 1bc9172bf0074342392f7e762ab93e9b9dd9a03ceb7be5e94cbe63da14cc1e21

Contents?: true

Size: 980 Bytes

Versions: 11

Compression:

Stored size: 980 Bytes

Contents

# frozen_string_literal: true

module Unparser
  class Emitter

    # Base class for special match node emitters
    class Match < self
      include Unterminated

      OPERATOR = '=~'.freeze

      # Emitter for match with local variable assignment
      class Lvasgn < self
        handle :match_with_lvasgn

        children :regexp, :lvasgn

      private

        # Perform dispatch
        #
        # @return [undefined]
        #
        # @api private
        #
        def dispatch
          visit(regexp)
          write(WS, OPERATOR, WS)
          visit(lvasgn)
        end

      end # Lvasgn

      # Emitter for match current line
      class CurrentLine < self
        handle :match_current_line

        children :regexp

        # Perform dispatch
        #
        # @return [undefined]
        #
        # @api private
        #
        def dispatch
          visit(regexp)
        end

      end # CurrentLine

    end # Match
  end # Emitter
end # Unparser

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
unparser-0.4.9 lib/unparser/emitter/match.rb
unparser-0.4.8 lib/unparser/emitter/match.rb
unparser-0.4.7 lib/unparser/emitter/match.rb
unparser-0.4.6 lib/unparser/emitter/match.rb
unparser-0.4.5 lib/unparser/emitter/match.rb
unparser-0.4.4 lib/unparser/emitter/match.rb
unparser-0.4.3 lib/unparser/emitter/match.rb
unparser-0.4.2 lib/unparser/emitter/match.rb
unparser-0.4.1 lib/unparser/emitter/match.rb
unparser-0.4.0 lib/unparser/emitter/match.rb
unparser-0.3.0 lib/unparser/emitter/match.rb