Module: Glossarist::Mentions::Resolver
- Defined in:
- lib/glossarist/mentions/resolver.rb
Overview
Resolves parsed mention segments against a resolution context. The context provides lookup callables; the resolver dispatches by mention kind + target type.
Class Method Summary collapse
-
.resolve(mention, context) ⇒ Hash
Resolved mention with :status.
- .resolve_all(mentions, context) ⇒ Object
Class Method Details
.resolve(mention, context) ⇒ Hash
Returns resolved mention with :status.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/glossarist/mentions/resolver.rb', line 14 def resolve(mention, context) return mention if mention[:kind] == "text" case mention[:kind] when "concept", "cite" resolve_concept(mention, context) when "fig", "table", "formula" resolve_entity(mention, context) when "bib" resolve_bib(mention, context) when "link" { status: "external", kind: "link", url: mention[:target][:url], label: mention[:label] } when "image" resolve_image(mention) else { status: "unresolved", kind: mention[:kind], target: mention[:target], label: mention[:label] } end end |
.resolve_all(mentions, context) ⇒ Object
35 36 37 |
# File 'lib/glossarist/mentions/resolver.rb', line 35 def resolve_all(mentions, context) mentions.map { |m| resolve(m, context) } end |