Class: GsImgFetcher::Manager
- Inherits:
-
Object
- Object
- GsImgFetcher::Manager
- Defined in:
- lib/gs_img_fetcher/manager.rb
Constant Summary collapse
- DEFAULT_MAX_THREADS =
Concurrent.processor_count
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#entry_set ⇒ Object
readonly
Returns the value of attribute entry_set.
-
#failed_fetches ⇒ Object
readonly
Returns the value of attribute failed_fetches.
-
#successful_fetches ⇒ Object
readonly
Returns the value of attribute successful_fetches.
Class Method Summary collapse
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(entry_set, output_dir: nil, async: true, max_threads: nil, max_size: nil) ⇒ Manager
constructor
A new instance of Manager.
- #setup ⇒ Object
Constructor Details
#initialize(entry_set, output_dir: nil, async: true, max_threads: nil, max_size: nil) ⇒ Manager
Returns a new instance of Manager.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gs_img_fetcher/manager.rb', line 18 def initialize(entry_set, output_dir: nil, async: true, max_threads: nil, max_size: nil) @entry_set = entry_set @output_dir = output_dir || Dir.pwd @async = async @max_threads = max_threads || DEFAULT_MAX_THREADS @max_size = max_size @entries = Queue.new @successful_fetches = Queue.new @failed_fetches = Queue.new end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
14 15 16 |
# File 'lib/gs_img_fetcher/manager.rb', line 14 def entries @entries end |
#entry_set ⇒ Object (readonly)
Returns the value of attribute entry_set.
14 15 16 |
# File 'lib/gs_img_fetcher/manager.rb', line 14 def entry_set @entry_set end |
#failed_fetches ⇒ Object (readonly)
Returns the value of attribute failed_fetches.
14 15 16 |
# File 'lib/gs_img_fetcher/manager.rb', line 14 def failed_fetches @failed_fetches end |
#successful_fetches ⇒ Object (readonly)
Returns the value of attribute successful_fetches.
14 15 16 |
# File 'lib/gs_img_fetcher/manager.rb', line 14 def successful_fetches @successful_fetches end |
Class Method Details
Instance Method Details
#fetch ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/gs_img_fetcher/manager.rb', line 39 def fetch @async ? async_fetch : sync_fetch log_result successful_fetches.close failed_fetches.close end |
#setup ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/gs_img_fetcher/manager.rb', line 29 def setup tap do log_entries next unless entries.empty? entry_set.valid_entries.each { |e| entries.push(e) } end end |