Class: Gorynich::Fetchers::File

Inherits:
Object
  • Object
show all
Defined in:
lib/gorynich/fetchers/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path:) ⇒ File

Returns a new instance of File.



9
10
11
# File 'lib/gorynich/fetchers/file.rb', line 9

def initialize(file_path:)
  @file_path = file_path
end

Instance Attribute Details

#file_pathObject (readonly)

Returns the value of attribute file_path.



7
8
9
# File 'lib/gorynich/fetchers/file.rb', line 7

def file_path
  @file_path
end

Instance Method Details

#fetchObject



13
14
15
16
17
18
19
# File 'lib/gorynich/fetchers/file.rb', line 13

def fetch
  data = ::ERB.new(::File.read(file_path)).result

  ::YAML.load(data, aliases: true) || {}
rescue ArgumentError
  ::YAML.load(data) || {}
end