Class: Patriot::Util::Config::IniFileConfig
- Defined in:
- lib/patriot/util/config/inifile_config.rb
Overview
a configuration implementation definied by the ini-file format
Constant Summary collapse
- COMMON_SECTION =
common section name
'common'
Instance Method Summary collapse
- #get(name, default = nil) ⇒ Object
-
#initialize(path, type = nil) ⇒ IniFileConfig
constructor
A new instance of IniFileConfig.
- #path ⇒ Object
Constructor Details
#initialize(path, type = nil) ⇒ IniFileConfig
Returns a new instance of IniFileConfig.
13 14 15 16 17 18 19 20 21 |
# File 'lib/patriot/util/config/inifile_config.rb', line 13 def initialize(path, type = nil) raise "path in String is expected but #{path.class}" unless path.is_a?(String) @path = path config = IniFile.load(path) raise "#{path} not found" if config.nil? @config = {} read_section(config, COMMON_SECTION) read_section(config, type) end |
Instance Method Details
#get(name, default = nil) ⇒ Object
40 41 42 43 44 |
# File 'lib/patriot/util/config/inifile_config.rb', line 40 def get(name, default=nil) v = @config[name.to_sym] v = split_value(v) return v.nil? ? default : v end |
#path ⇒ Object
35 36 37 |
# File 'lib/patriot/util/config/inifile_config.rb', line 35 def path return @path end |