Module: Coradoc::AsciiDoc::Model::Resolvable
- Included in:
- Include
- Defined in:
- lib/coradoc/asciidoc/model/resolvable.rb
Overview
Module for nodes that reference external resources.
Any model element that references an external file or resource should include this module to provide a unified interface for resolution operations.
Instance Method Summary collapse
-
#local_reference? ⇒ Boolean
Checks if the reference is to a local file.
-
#reference_options ⇒ Hash
Returns additional options for reference resolution.
-
#reference_path ⇒ String
Returns the path to the external resource.
-
#reference_type ⇒ Symbol
Returns the type of reference.
-
#remote_reference? ⇒ Boolean
Checks if the reference is to a remote URL.
Instance Method Details
#local_reference? ⇒ Boolean
Checks if the reference is to a local file.
54 55 56 57 58 59 60 |
# File 'lib/coradoc/asciidoc/model/resolvable.rb', line 54 def local_reference? path = reference_path return false if path.nil? # Not a URL if it doesn't start with a scheme !path.match?(%r{^[a-z][a-z0-9+.-]*://}i) end |
#reference_options ⇒ Hash
Returns additional options for reference resolution.
47 48 49 |
# File 'lib/coradoc/asciidoc/model/resolvable.rb', line 47 def {} end |
#reference_path ⇒ String
Returns the path to the external resource.
30 31 32 33 |
# File 'lib/coradoc/asciidoc/model/resolvable.rb', line 30 def reference_path raise NotImplementedError, "#{self.class} must implement #reference_path" end |
#reference_type ⇒ Symbol
Returns the type of reference.
39 40 41 42 |
# File 'lib/coradoc/asciidoc/model/resolvable.rb', line 39 def reference_type raise NotImplementedError, "#{self.class} must implement #reference_type" end |
#remote_reference? ⇒ Boolean
Checks if the reference is to a remote URL.
65 66 67 |
# File 'lib/coradoc/asciidoc/model/resolvable.rb', line 65 def remote_reference? !local_reference? end |