Class: Ace::Retro::Molecules::RetroResolver
- Inherits:
-
Object
- Object
- Ace::Retro::Molecules::RetroResolver
- Defined in:
- lib/ace/retro/molecules/retro_resolver.rb
Overview
Wraps ShortcutResolver for raw retro IDs (no type marker). Resolves 3-char suffix shortcuts, full 6-char IDs. Explicitly detects and warns on ambiguity collisions.
Instance Method Summary collapse
-
#initialize(root_dir) ⇒ RetroResolver
constructor
A new instance of RetroResolver.
-
#resolve(ref, warn_on_ambiguity: true) ⇒ ScanResult?
Resolve a reference to a scan result.
-
#resolve_with_info(ref) ⇒ Hash
Resolve with explicit ambiguity detection.
Constructor Details
#initialize(root_dir) ⇒ RetroResolver
Returns a new instance of RetroResolver.
14 15 16 17 |
# File 'lib/ace/retro/molecules/retro_resolver.rb', line 14 def initialize(root_dir) @root_dir = root_dir @scanner = RetroScanner.new(root_dir) end |
Instance Method Details
#resolve(ref, warn_on_ambiguity: true) ⇒ ScanResult?
Resolve a reference to a scan result
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ace/retro/molecules/retro_resolver.rb', line 23 def resolve(ref, warn_on_ambiguity: true) scan_results = @scanner.scan resolver = Ace::Support::Items::Molecules::ShortcutResolver.new(scan_results) on_ambiguity = if warn_on_ambiguity ->(matches) { ids = matches.map(&:id).join(", ") warn "Warning: Ambiguous shortcut '#{ref}' matches #{matches.size} retros: #{ids}. Using most recent." } end resolver.resolve(ref, on_ambiguity: on_ambiguity) end |
#resolve_with_info(ref) ⇒ Hash
Resolve with explicit ambiguity detection
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ace/retro/molecules/retro_resolver.rb', line 40 def resolve_with_info(ref) scan_results = @scanner.scan resolver = Ace::Support::Items::Molecules::ShortcutResolver.new(scan_results) matches = resolver.all_matches(ref) if matches.empty? {result: nil, ambiguous: false, matches: []} elsif matches.size == 1 {result: matches.first, ambiguous: false, matches: matches} else {result: matches.last, ambiguous: true, matches: matches} end end |