Class: TechnoGate::TgConfig
- Inherits:
-
Object
- Object
- TechnoGate::TgConfig
- Defined in:
- lib/tg_config.rb,
lib/tg_config/errors.rb,
lib/tg_config/version.rb
Constant Summary collapse
- TgConfigError =
Class.new Exception
- NotReadableError =
Class.new TgConfigError
- NotDefinedError =
Class.new TgConfigError
- NotWritableError =
Class.new TgConfigError
- NotValidError =
Class.new TgConfigError
- IsEmptyError =
Class.new TgConfigError
- ConfigFileNotSetError =
Class.new TgConfigError
- MAJOR =
0
- MINOR =
1
- TINY =
4
- PRE =
''
Instance Attribute Summary collapse
-
#config_file ⇒ Object
readonly
Returns the value of attribute config_file.
Class Method Summary collapse
Instance Method Summary collapse
-
#[](config) ⇒ Object
Return a particular config variable from the parsed config file.
-
#[]=(config, value) ⇒ Object
Update the config file.
-
#initialize(config_file) ⇒ TgConfig
constructor
A new instance of TgConfig.
-
#save ⇒ Object
Save the config file.
Constructor Details
#initialize(config_file) ⇒ TgConfig
Returns a new instance of TgConfig.
14 15 16 17 18 |
# File 'lib/tg_config.rb', line 14 def initialize(config_file) @config_file = config_file check_config_file @config = parse_config_file end |
Instance Attribute Details
#config_file ⇒ Object (readonly)
Returns the value of attribute config_file.
12 13 14 |
# File 'lib/tg_config.rb', line 12 def config_file @config_file end |
Class Method Details
Instance Method Details
#[](config) ⇒ Object
Return a particular config variable from the parsed config file
25 26 27 28 29 30 31 |
# File 'lib/tg_config.rb', line 25 def [](config) unless @config check_config_file @config = parse_config_file end @config.send(:[], config) end |
#[]=(config, value) ⇒ Object
Update the config file
37 38 39 40 41 42 43 |
# File 'lib/tg_config.rb', line 37 def []=(config, value) unless @config check_config_file @config = parse_config_file end @config.send(:[]=, config, value) end |
#save ⇒ Object
Save the config file
46 47 48 49 50 51 |
# File 'lib/tg_config.rb', line 46 def save # Make sure the config file is writable check_config_file(true) # Write the config file write_config_file end |