Sha256: 8118871788f75bfd47a2488f6df133f1220e09710c6c2ea79e3986297b0b9a97

Contents?: true

Size: 945 Bytes

Versions: 4

Compression:

Stored size: 945 Bytes

Contents

# frozen_string_literal: true

class FastIgnore
  class Rule
    attr_reader :negation
    alias_method :negation?, :negation
    undef :negation

    attr_reader :dir_only
    alias_method :dir_only?, :dir_only
    undef :dir_only

    attr_reader :unanchored
    alias_method :unanchored?, :unanchored
    undef :unanchored

    attr_reader :type
    attr_reader :rule

    def initialize(rule, negation, unanchored = nil, dir_only = nil)
      @rule = rule.is_a?(Regexp) ? rule : ::FastIgnore::FNMatchToRegex.call(rule)
      @unanchored = unanchored
      @dir_only = dir_only
      @negation = negation

      @type = negation ? 1 : 0

      freeze
    end

    def file_only?
      false
    end

    def shebang
      nil
    end

    # :nocov:
    def inspect
      "#<Rule #{'!' if @negation}#{@rule}#{'/' if @dir_only}>"
    end
    # :nocov:

    def match?(relative_path, _, _, _)
      @rule.match?(relative_path)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fast_ignore-0.13.0 lib/fast_ignore/rule.rb
fast_ignore-0.12.1 lib/fast_ignore/rule.rb
fast_ignore-0.12.0 lib/fast_ignore/rule.rb
fast_ignore-0.11.0 lib/fast_ignore/rule.rb