Class: PRC::SectionConfig
- Inherits:
-
BaseConfig
- Object
- BaseConfig
- PRC::SectionConfig
- Defined in:
- lib/prc_section_config.rb
Overview
SectionConfig class layer based on BaseConfig.
It supports a data_options :section for #[], #[]=, etc…
Instance Attribute Summary
Attributes inherited from BaseConfig
#data, #filename, #latest_version, #version
Instance Method Summary collapse
-
#[](*keys) ⇒ Object
Get the value of a specific key under a section.
-
#[]=(*keys, value) ⇒ Object
Set the value of a specific key under a section.
-
#del(*keys) ⇒ Object
remove the key under a section.
-
#exist?(*keys) ⇒ Boolean
Check key existence under a section.
Methods inherited from BaseConfig
#data_options, #erase, #initialize, #latest_version?, #load, #rh_key_to_symbol, #rh_key_to_symbol?, #save, #to_s
Constructor Details
This class inherits a constructor from PRC::BaseConfig
Instance Method Details
#[](*keys) ⇒ Object
Get the value of a specific key under a section. You have to call #data_options(:section => ‘MySection’)
-
Args :
-
keys: keys to get values from a section set by data_options. If section is not set, it will use :default
-
-
Returns :
-
key value.
-
-
Raises : Nothing
36 37 38 39 40 |
# File 'lib/prc_section_config.rb', line 36 def [](*keys) return nil if keys.length == 0 return p_get(:default, *keys) if @data_options[:section].nil? p_get(@data_options[:section], *keys) end |
#[]=(*keys, value) ⇒ Object
Set the value of a specific key under a section. You have to call #data_options(:section => ‘MySection’)
-
Args :
-
keys: keys to get values from a section set by data_options. If section is not set, it will use :default
-
-
Returns :
-
key value.
-
-
Raises : Nothing
52 53 54 55 56 |
# File 'lib/prc_section_config.rb', line 52 def []=(*keys, value) return nil if keys.length == 0 return p_set(:default, *keys, value) if @data_options[:section].nil? p_set(@data_options[:section], *keys, value) end |
#del(*keys) ⇒ Object
remove the key under a section. You have to call #data_options(:section => ‘MySection’)
-
Args :
-
keys: keys to get values from a section set by data_options. If section is not set, it will use :default
-
-
Returns :
-
key value.
-
-
Raises : Nothing
84 85 86 87 88 |
# File 'lib/prc_section_config.rb', line 84 def del(*keys) return nil if keys.length == 0 return p_del(:default, *keys) if @data_options[:section].nil? p_del(@data_options[:section], *keys) end |
#exist?(*keys) ⇒ Boolean
Check key existence under a section. You have to call #data_options(:section => ‘MySection’)
-
Args :
-
keys: keys to get values from a section set by data_options. If section is not set, it will use :default
-
-
Returns :
-
key value.
-
-
Raises : Nothing
68 69 70 71 72 |
# File 'lib/prc_section_config.rb', line 68 def exist?(*keys) return nil if keys.length == 0 return p_exist?(:default, *keys) if @data_options[:section].nil? p_exist?(@data_options[:section], *keys) end |