Class: FileMonitorFilter
- Inherits:
-
Object
- Object
- FileMonitorFilter
- Defined in:
- lib/file-monitor.rb
Instance Method Summary collapse
- #allow(pattern) ⇒ Object (also: #a)
- #disallow(pattern) ⇒ Object (also: #d)
- #ignored?(path) ⇒ Boolean (also: #disallow?)
-
#initialize ⇒ FileMonitorFilter
constructor
A new instance of FileMonitorFilter.
- #reset ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ FileMonitorFilter
Returns a new instance of FileMonitorFilter.
8 9 10 |
# File 'lib/file-monitor.rb', line 8 def initialize @patterns = [] end |
Instance Method Details
#allow(pattern) ⇒ Object Also known as: a
28 29 30 |
# File 'lib/file-monitor.rb', line 28 def allow(pattern) @patterns << [:allow, pattern] end |
#disallow(pattern) ⇒ Object Also known as: d
24 25 26 |
# File 'lib/file-monitor.rb', line 24 def disallow(pattern) @patterns << [:disallow, pattern] end |
#ignored?(path) ⇒ Boolean Also known as: disallow?
12 13 14 15 16 17 18 19 20 |
# File 'lib/file-monitor.rb', line 12 def ignored?(path) status = :allow for mode, pattern in @patterns if path =~ pattern status = mode end end return status == :disallow end |
#reset ⇒ Object
32 33 34 |
# File 'lib/file-monitor.rb', line 32 def reset @patterns = [] end |
#to_s ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/file-monitor.rb', line 36 def to_s str = StringIO.new for pattern in @patterns str.puts "#{pattern[0].to_s} #{pattern[1].inspect}" end str.string end |