Class: Idml::Render::HyperlinkResolver
- Inherits:
-
Object
- Object
- Idml::Render::HyperlinkResolver
- Defined in:
- lib/idml/render/hyperlink_resolver.rb
Overview
Resolves IDML hyperlink definitions to URL destinations. Looks
up Hyperlink#source → Hyperlink#destination →
HyperlinkURLDestination#destination_url from the designmap.
The renderer is responsible for mapping source Self IDs to page-item rectangles; this resolver only handles the destination lookup.
Instance Method Summary collapse
-
#each_visible ⇒ Object
Yields [source_self, url] for every visible hyperlink whose destination chain resolves to a URL.
-
#initialize(package) ⇒ HyperlinkResolver
constructor
A new instance of HyperlinkResolver.
-
#url_for_source(source_self) ⇒ Object
Returns the URL for the given hyperlink-source Self, or nil.
Constructor Details
#initialize(package) ⇒ HyperlinkResolver
Returns a new instance of HyperlinkResolver.
13 14 15 |
# File 'lib/idml/render/hyperlink_resolver.rb', line 13 def initialize(package) @package = package end |
Instance Method Details
#each_visible ⇒ Object
Yields [source_self, url] for every visible hyperlink whose destination chain resolves to a URL.
29 30 31 32 33 34 35 36 |
# File 'lib/idml/render/hyperlink_resolver.rb', line 29 def each_visible return enum_for(:each_visible) unless block_given? hyperlinks.each do |hyperlink| entry = visible_entry(hyperlink) yield(*entry) if entry end end |
#url_for_source(source_self) ⇒ Object
Returns the URL for the given hyperlink-source Self, or nil.
18 19 20 21 22 23 24 25 |
# File 'lib/idml/render/hyperlink_resolver.rb', line 18 def url_for_source(source_self) return nil unless source_self hyperlink = hyperlink_by_source(source_self) return nil unless hyperlink url_destination_by_self(hyperlink.destination)&.destination_url end |