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.



12
13
14
# File 'lib/yle_tf/config/file.rb', line 12

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#readObject



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

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

#to_sObject



23
24
25
# File 'lib/yle_tf/config/file.rb', line 23

def to_s
  name
end