Class: YamlReader

Inherits:
Reader show all
Defined in:
lib/teuton-get/reader/yaml_reader.rb

Instance Method Summary collapse

Constructor Details

#initialize(filepath = "") ⇒ YamlReader

Returns a new instance of YamlReader.



6
7
8
# File 'lib/teuton-get/reader/yaml_reader.rb', line 6

def initialize(filepath = "")
  @filepath = filepath
end

Instance Method Details

#read(filepath = :default) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/teuton-get/reader/yaml_reader.rb', line 14

def read(filepath = :default)
  @filepath = filepath unless filepath == :default
  return {} unless File.exist? @filepath

  content = File.open(@filepath)
  YAML.safe_load(
    content,
    permitted_classes: [Array, Date, Hash, Symbol]
  )
end

#sourceObject



10
11
12
# File 'lib/teuton-get/reader/yaml_reader.rb', line 10

def source
  @filepath
end