Sha256: 751be22bdda2795d0cc2aee7bb76030589e3c7de76563a2e6e8a606d1a9b0b8c

Contents?: true

Size: 619 Bytes

Versions: 32

Compression:

Stored size: 619 Bytes

Contents

# frozen_string_literal: true

module Pragmater
  # Handles pragma comments.
  class Commenter
    def initialize older, newer, formatter: Formatter
      @formatter = formatter
      @older = format older
      @newer = format newer
    end

    def add
      older | newer
    end

    def remove
      older - (older & newer)
    end

    private

    attr_reader :older, :newer, :formatter

    def filter comments
      Array(comments).select { |comment| comment =~ formatter.valid_formats }
    end

    def format comments
      filter(comments).map { |comment| formatter.new(comment).format }
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
pragmater-7.2.0 lib/pragmater/commenter.rb
pragmater-7.1.0 lib/pragmater/commenter.rb
pragmater-7.0.1 lib/pragmater/commenter.rb
pragmater-7.0.0 lib/pragmater/commenter.rb
pragmater-6.3.3 lib/pragmater/commenter.rb
pragmater-6.3.2 lib/pragmater/commenter.rb
pragmater-6.3.1 lib/pragmater/commenter.rb
pragmater-6.3.0 lib/pragmater/commenter.rb
pragmater-6.2.1 lib/pragmater/commenter.rb
pragmater-6.2.0 lib/pragmater/commenter.rb
pragmater-6.1.0 lib/pragmater/commenter.rb
pragmater-6.0.0 lib/pragmater/commenter.rb
pragmater-5.2.0 lib/pragmater/commenter.rb
pragmater-5.1.0 lib/pragmater/commenter.rb
pragmater-5.0.2 lib/pragmater/commenter.rb
pragmater-5.0.1 lib/pragmater/commenter.rb
pragmater-5.0.0 lib/pragmater/commenter.rb
pragmater-4.3.1 lib/pragmater/commenter.rb
pragmater-4.3.0 lib/pragmater/commenter.rb
pragmater-4.2.0 lib/pragmater/commenter.rb