Class: Ace::Hitl::Molecules::HitlScanner
- Inherits:
-
Object
- Object
- Ace::Hitl::Molecules::HitlScanner
- Defined in:
- lib/ace/hitl/molecules/hitl_scanner.rb
Instance Attribute Summary collapse
-
#last_folder_counts ⇒ Object
readonly
Returns the value of attribute last_folder_counts.
-
#last_scan_total ⇒ Object
readonly
Returns the value of attribute last_scan_total.
Instance Method Summary collapse
-
#initialize(root_dir) ⇒ HitlScanner
constructor
A new instance of HitlScanner.
- #scan ⇒ Object
- #scan_in_folder(folder) ⇒ Object
Constructor Details
#initialize(root_dir) ⇒ HitlScanner
Returns a new instance of HitlScanner.
12 13 14 15 16 17 18 |
# File 'lib/ace/hitl/molecules/hitl_scanner.rb', line 12 def initialize(root_dir) @root_dir = root_dir @scanner = Ace::Support::Items::Molecules::DirectoryScanner.new( root_dir, file_pattern: Atoms::HitlFilePattern::FILE_GLOB ) end |
Instance Attribute Details
#last_folder_counts ⇒ Object (readonly)
Returns the value of attribute last_folder_counts.
10 11 12 |
# File 'lib/ace/hitl/molecules/hitl_scanner.rb', line 10 def last_folder_counts @last_folder_counts end |
#last_scan_total ⇒ Object (readonly)
Returns the value of attribute last_scan_total.
10 11 12 |
# File 'lib/ace/hitl/molecules/hitl_scanner.rb', line 10 def last_scan_total @last_scan_total end |
Instance Method Details
#scan ⇒ Object
20 21 22 |
# File 'lib/ace/hitl/molecules/hitl_scanner.rb', line 20 def scan @scanner.scan end |
#scan_in_folder(folder) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ace/hitl/molecules/hitl_scanner.rb', line 24 def scan_in_folder(folder) results = scan @last_scan_total = results.size @last_folder_counts = results.group_by(&:special_folder).transform_values(&:size) return results if folder.nil? virtual = Ace::Support::Items::Atoms::SpecialFolderDetector.virtual_filter?(folder) case virtual when :all then results when :next then results.select { |r| r.special_folder.nil? } else normalized = Ace::Support::Items::Atoms::SpecialFolderDetector.normalize(folder) results.select { |r| r.special_folder == normalized } end end |