Class: ConfigToolkit::YAMLReader
- Defined in:
- lib/configtoolkit/yamlreader.rb
Overview
This class implements the Reader interface for YAML configuration files. It basically is a wrapper over Ruby’s YAML library.
See YAML.txt for more details.
Instance Method Summary collapse
-
#initialize(stream) ⇒ YAMLReader
constructor
Description: This constructs a YAMLReader instance for
stream
, wherestream
either is a file name (a String) or an IO object. -
#read ⇒ Object
Returns: The contents of the next YAML document read from the underlying stream.
Methods inherited from Reader
Constructor Details
#initialize(stream) ⇒ YAMLReader
Description:
This constructs a YAMLReader instance for stream
, where stream
either is a file name (a String) or an IO object.
Parameters:
- stream
-
A file name (String) or an IO object. If
stream
is a file name, then the YAMLReader will open the associated file.
28 29 30 31 32 33 34 |
# File 'lib/configtoolkit/yamlreader.rb', line 28 def initialize(stream) if(stream.class == String) @stream = File.open(stream, "r") else @stream = stream end end |
Instance Method Details
#read ⇒ Object
Returns:
The contents of the next YAML document read from the underlying stream.
41 42 43 |
# File 'lib/configtoolkit/yamlreader.rb', line 41 def read return YAML::load(@stream) end |