Class: Barabara::Configuration
- Inherits:
-
Object
- Object
- Barabara::Configuration
- Defined in:
- lib/barabara/config.rb
Overview
Load configuration from a file and store it as an object.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#modules ⇒ Object
readonly
Returns the value of attribute modules.
-
#monitors ⇒ Object
readonly
Returns the value of attribute monitors.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Class Method Summary collapse
Instance Method Summary collapse
- #colors ⇒ Object
-
#initialize(config_file) ⇒ Configuration
constructor
A new instance of Configuration.
- #module_config(mod_name) ⇒ Object
- #module_options ⇒ Object
Constructor Details
#initialize(config_file) ⇒ Configuration
Returns a new instance of Configuration.
13 14 15 16 17 18 |
# File 'lib/barabara/config.rb', line 13 def initialize(config_file) @config = YAML.load_file config_file @modules = parse_module_list(@config['modules']) @session = ENV['XDG_SESSION_DESKTOP'] @monitors = Modules::WM.get_monitors(@session) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
11 12 13 |
# File 'lib/barabara/config.rb', line 11 def config @config end |
#modules ⇒ Object (readonly)
Returns the value of attribute modules.
11 12 13 |
# File 'lib/barabara/config.rb', line 11 def modules @modules end |
#monitors ⇒ Object (readonly)
Returns the value of attribute monitors.
11 12 13 |
# File 'lib/barabara/config.rb', line 11 def monitors @monitors end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
11 12 13 |
# File 'lib/barabara/config.rb', line 11 def session @session end |
Class Method Details
.dump_default_config(path) ⇒ Object
29 30 31 32 33 |
# File 'lib/barabara/config.rb', line 29 def self.dump_default_config(path) File.open(File.(path), 'w') do |f| f.write default_config.to_yaml end end |
Instance Method Details
#colors ⇒ Object
20 |
# File 'lib/barabara/config.rb', line 20 def colors; @config['colors']; end |
#module_config(mod_name) ⇒ Object
23 24 25 26 27 |
# File 'lib/barabara/config.rb', line 23 def module_config(mod_name) return {} unless .key?(mod_name) [mod_name] end |
#module_options ⇒ Object
21 |
# File 'lib/barabara/config.rb', line 21 def ; @config['module_options']; end |