Class: Reynard::External
- Inherits:
-
Object
- Object
- Reynard::External
- Defined in:
- lib/reynard/external.rb
Overview
Loads external references.
Instance Method Summary collapse
- #data ⇒ Object
- #filesystem_path ⇒ Object
-
#initialize(path:, ref:) ⇒ External
constructor
A new instance of External.
- #path ⇒ Object
Constructor Details
#initialize(path:, ref:) ⇒ External
Returns a new instance of External.
8 9 10 11 12 |
# File 'lib/reynard/external.rb', line 8 def initialize(path:, ref:) @path = path @relative_path, @anchor = ref.split('#', 2) @filename = File.(@relative_path, @path) end |
Instance Method Details
#data ⇒ Object
20 21 22 23 24 |
# File 'lib/reynard/external.rb', line 20 def data File.open(filename, encoding: 'UTF-8') do |file| YAML.safe_load(file, aliases: true) end end |
#filesystem_path ⇒ Object
26 27 28 |
# File 'lib/reynard/external.rb', line 26 def filesystem_path File.dirname(@filename) end |
#path ⇒ Object
14 15 16 17 18 |
# File 'lib/reynard/external.rb', line 14 def path return [] unless @anchor @anchor.split('/')[1..] end |