Class: Reynard::External

Inherits:
Object
  • Object
show all
Defined in:
lib/reynard/external.rb

Overview

Loads external references.

Instance Method Summary collapse

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.expand_path(@relative_path, @path)
end

Instance Method Details

#dataObject



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_pathObject



26
27
28
# File 'lib/reynard/external.rb', line 26

def filesystem_path
  File.dirname(@filename)
end

#pathObject



14
15
16
17
18
# File 'lib/reynard/external.rb', line 14

def path
  return [] unless @anchor

  @anchor.split('/')[1..]
end