Sha256: ed98967be6a2ee3589cdde92cb3cd2c73ab764ae73c9299e989f130a54caae96

Contents?: true

Size: 585 Bytes

Versions: 10

Compression:

Stored size: 585 Bytes

Contents

# frozen_string_literal: true

module Pragmater
  module Parsers
    # Manages pragma comments.
    class Comments
      def initialize older, newer, formatter: Formatters::Main
        @formatter = formatter
        @older = format older
        @newer = format newer
      end

      def insert
        older.union newer
      end

      def remove
        older - older.intersection(newer)
      end

      private

      attr_reader :formatter, :older, :newer

      def format pragmas
        Array(pragmas).map { |pragma| formatter.new(pragma).call }
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pragmater-9.3.0 lib/pragmater/parsers/comments.rb
pragmater-9.2.0 lib/pragmater/parsers/comments.rb
pragmater-9.1.2 lib/pragmater/parsers/comments.rb
pragmater-9.1.1 lib/pragmater/parsers/comments.rb
pragmater-9.1.0 lib/pragmater/parsers/comments.rb
pragmater-9.0.0 lib/pragmater/parsers/comments.rb
pragmater-8.3.0 lib/pragmater/parsers/comments.rb
pragmater-8.2.0 lib/pragmater/parsers/comments.rb
pragmater-8.1.0 lib/pragmater/parsers/comments.rb
pragmater-8.0.0 lib/pragmater/parsers/comments.rb