Sha256: 84731130252a457a83cd173948f8f019e989ee000f05371bbed27e5fb139406f

Contents?: true

Size: 556 Bytes

Versions: 8

Compression:

Stored size: 556 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    # Common functionality for working with heredoc strings.
    module Heredoc
      OPENING_DELIMITER = /<<[~-]?['"`]?([^'"`]+)['"`]?/

      def on_str(node)
        return unless node.heredoc?

        on_heredoc(node)
      end
      alias on_dstr on_str
      alias on_xstr on_str

      def on_heredoc(_node)
        raise NotImplementedError
      end

      private

      def delimiter_string(node)
        node.source.match(OPENING_DELIMITER).captures.first
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rubocop-0.57.1 lib/rubocop/cop/mixin/heredoc.rb
rubocop-0.57.0 lib/rubocop/cop/mixin/heredoc.rb
rubocop-0.56.0 lib/rubocop/cop/mixin/heredoc.rb
rubocop-0.55.0 lib/rubocop/cop/mixin/heredoc.rb
rubocop-0.54.0 lib/rubocop/cop/mixin/heredoc.rb
rubocop-0.53.0 lib/rubocop/cop/mixin/heredoc.rb
rubocop-0.52.1 lib/rubocop/cop/mixin/heredoc.rb
rubocop-0.52.0 lib/rubocop/cop/mixin/heredoc.rb