Class: YleTf::Config::File

Inherits:
Object
  • Object
show all
Defined in:
lib/yle_tf/config/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ File

Returns a new instance of File.



10
11
12
# File 'lib/yle_tf/config/file.rb', line 10

def initialize(name)
  @name = name.to_s
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/yle_tf/config/file.rb', line 8

def name
  @name
end

Instance Method Details

#readObject



14
15
16
17
18
19
# File 'lib/yle_tf/config/file.rb', line 14

def read
  YAML.load_file(name) || {}
rescue StandardError => e
  Logger.fatal("Failed to load or parse configuration from '#{name}'")
  raise e
end

#to_sObject



21
22
23
# File 'lib/yle_tf/config/file.rb', line 21

def to_s
  name
end