Class: FastIgnore::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/fast_ignore/rule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rule, negation, unanchored = nil, dir_only = nil) ⇒ Rule

Returns a new instance of Rule.



20
21
22
23
24
25
26
27
28
29
# File 'lib/fast_ignore/rule.rb', line 20

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

Instance Attribute Details

#dir_onlyObject (readonly) Also known as: dir_only?

Returns the value of attribute dir_only.



9
10
11
# File 'lib/fast_ignore/rule.rb', line 9

def dir_only
  @dir_only
end

#negationObject (readonly) Also known as: negation?

Returns the value of attribute negation.



5
6
7
# File 'lib/fast_ignore/rule.rb', line 5

def negation
  @negation
end

#ruleObject (readonly)

Returns the value of attribute rule.



18
19
20
# File 'lib/fast_ignore/rule.rb', line 18

def rule
  @rule
end

#typeObject (readonly)

Returns the value of attribute type.



17
18
19
# File 'lib/fast_ignore/rule.rb', line 17

def type
  @type
end

#unanchoredObject (readonly) Also known as: unanchored?

Returns the value of attribute unanchored.



13
14
15
# File 'lib/fast_ignore/rule.rb', line 13

def unanchored
  @unanchored
end

Instance Method Details

#file_only?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/fast_ignore/rule.rb', line 31

def file_only?
  false
end

#inspectObject

:nocov:



40
41
42
# File 'lib/fast_ignore/rule.rb', line 40

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

#match?(relative_path, _, _, _) ⇒ Boolean

:nocov:

Returns:

  • (Boolean)


45
46
47
# File 'lib/fast_ignore/rule.rb', line 45

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

#shebangObject



35
36
37
# File 'lib/fast_ignore/rule.rb', line 35

def shebang
  nil
end