Class: Gorynich::Fetchers::File
- Inherits:
-
Object
- Object
- Gorynich::Fetchers::File
- Defined in:
- lib/gorynich/fetchers/file.rb
Instance Attribute Summary collapse
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(file_path:) ⇒ File
constructor
A new instance of File.
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_path ⇒ Object (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
#fetch ⇒ Object
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 |