Class: FastIgnore::ShebangRule
- Inherits:
-
Object
- Object
- FastIgnore::ShebangRule
- Defined in:
- lib/fast_ignore/shebang_rule.rb
Instance Attribute Summary collapse
-
#negation ⇒ Object
(also: #negation?)
readonly
Returns the value of attribute negation.
-
#rule ⇒ Object
(also: #shebang)
readonly
Returns the value of attribute rule.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #dir_only? ⇒ Boolean
- #file_only? ⇒ Boolean
-
#initialize(rule, negation) ⇒ ShebangRule
constructor
A new instance of ShebangRule.
-
#inspect ⇒ Object
:nocov:.
-
#match?(_, full_path, filename, content) ⇒ Boolean
:nocov:.
- #unanchored? ⇒ Boolean
Constructor Details
#initialize(rule, negation) ⇒ ShebangRule
Returns a new instance of ShebangRule.
14 15 16 17 18 19 20 21 22 |
# File 'lib/fast_ignore/shebang_rule.rb', line 14 def initialize(rule, negation) @rule = rule @negation = negation @type = 2 @type += 1 if negation freeze end |
Instance Attribute Details
#negation ⇒ Object (readonly) Also known as: negation?
Returns the value of attribute negation.
5 6 7 |
# File 'lib/fast_ignore/shebang_rule.rb', line 5 def negation @negation end |
#rule ⇒ Object (readonly) Also known as: shebang
Returns the value of attribute rule.
9 10 11 |
# File 'lib/fast_ignore/shebang_rule.rb', line 9 def rule @rule end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
12 13 14 |
# File 'lib/fast_ignore/shebang_rule.rb', line 12 def type @type end |
Instance Method Details
#dir_only? ⇒ Boolean
28 29 30 |
# File 'lib/fast_ignore/shebang_rule.rb', line 28 def dir_only? false end |
#file_only? ⇒ Boolean
24 25 26 |
# File 'lib/fast_ignore/shebang_rule.rb', line 24 def file_only? true end |
#inspect ⇒ Object
:nocov:
37 38 39 |
# File 'lib/fast_ignore/shebang_rule.rb', line 37 def inspect "#<ShebangRule #{'allow ' if @negation}#!:#{@rule.to_s[15..-4]}>" end |
#match?(_, full_path, filename, content) ⇒ Boolean
:nocov:
42 43 44 45 46 |
# File 'lib/fast_ignore/shebang_rule.rb', line 42 def match?(_, full_path, filename, content) return false if filename.include?('.') (content || first_line(full_path))&.match?(@rule) end |
#unanchored? ⇒ Boolean
32 33 34 |
# File 'lib/fast_ignore/shebang_rule.rb', line 32 def unanchored? true end |