Class: Macinbox::Collector
- Inherits:
-
Object
- Object
- Macinbox::Collector
- Defined in:
- lib/macinbox/collector.rb
Instance Method Summary collapse
- #add_temp_dir(temp_dir) ⇒ Object
- #cleanup! ⇒ Object
-
#initialize ⇒ Collector
constructor
A new instance of Collector.
- #on_cleanup(&block) ⇒ Object
- #remove_temp_dirs ⇒ Object
- #temp_dirs ⇒ Object
Constructor Details
#initialize ⇒ Collector
Returns a new instance of Collector.
5 6 7 8 |
# File 'lib/macinbox/collector.rb', line 5 def initialize @temp_dirs = [] @blocks = [] end |
Instance Method Details
#add_temp_dir(temp_dir) ⇒ Object
9 10 11 |
# File 'lib/macinbox/collector.rb', line 9 def add_temp_dir(temp_dir) @temp_dirs << temp_dir end |
#cleanup! ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/macinbox/collector.rb', line 23 def cleanup! @blocks.reverse.each do |block| block.call end @blocks = [] @temp_dirs = [] end |
#on_cleanup(&block) ⇒ Object
20 21 22 |
# File 'lib/macinbox/collector.rb', line 20 def on_cleanup(&block) @blocks << block end |
#remove_temp_dirs ⇒ Object
15 16 17 18 19 |
# File 'lib/macinbox/collector.rb', line 15 def remove_temp_dirs @temp_dirs.reverse.each do |temp_dir| FileUtils.remove_dir(temp_dir) end end |
#temp_dirs ⇒ Object
12 13 14 |
# File 'lib/macinbox/collector.rb', line 12 def temp_dirs @temp_dirs end |