Class: YamlReader
Instance Method Summary collapse
-
#initialize(filepath = "") ⇒ YamlReader
constructor
A new instance of YamlReader.
- #read(filepath = :default) ⇒ Object
- #source ⇒ Object
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 |
#source ⇒ Object
10 11 12 |
# File 'lib/teuton-get/reader/yaml_reader.rb', line 10 def source @filepath end |