Class: ConfigToolkit::KeyValueReader
- Defined in:
- lib/configtoolkit/keyvaluereader.rb
Overview
This class implements the Reader interface for key-value configuration files.
See KeyValue.txt for more details about the key-value configuration format.
Defined Under Namespace
Classes: ContainerParsingFrame, HashEntry, ParsingError
Instance Method Summary collapse
-
#initialize(stream, config = KeyValueConfig::DEFAULT_CONFIG) ⇒ KeyValueReader
constructor
Description: This constructs a KeyValueReader instance for a key-value format described by
config
forstream
, where stream is either a file name (a String) or an IO object. -
#read ⇒ Object
Returns: The contents of the key-value configuration file.
Methods inherited from Reader
Constructor Details
#initialize(stream, config = KeyValueConfig::DEFAULT_CONFIG) ⇒ KeyValueReader
Description:
This constructs a KeyValueReader instance for a key-value format described by config
for stream
, where stream is either 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 KeyValueReader will open the associated file. - config
-
A KeyValueConfig that defines the format of the key-value input that this instance can read
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/configtoolkit/keyvaluereader.rb', line 43 def initialize(stream, config = KeyValueConfig::DEFAULT_CONFIG) if(stream.class == String) @stream = File.open(stream, "r") else @stream = stream end @stream_path = Reader.stream_path(stream) @config = config end |
Instance Method Details
#read ⇒ Object
Returns:
The contents of the key-value configuration file
588 589 590 591 592 593 594 |
# File 'lib/configtoolkit/keyvaluereader.rb', line 588 def read param_hash = {} read_impl(param_hash, @stream, @stream_path) return param_hash end |