Class: YMDP::Configuration::Base
- Inherits:
-
Object
- Object
- YMDP::Configuration::Base
- Defined in:
- lib/ymdp/configuration/config.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
Returns the value of attribute base.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #each ⇒ Object
- #exists?(*args) ⇒ Boolean
- #file_not_found(filename) ⇒ Object
-
#initialize(filename, base) ⇒ Base
constructor
A new instance of Base.
- #options(*args) ⇒ Object
Constructor Details
#initialize(filename, base) ⇒ Base
Returns a new instance of Base.
97 98 99 100 101 102 103 104 |
# File 'lib/ymdp/configuration/config.rb', line 97 def initialize(filename, base) if File.exists?(filename) @config = Serenity::Configuration.new(filename) @base = base else file_not_found(filename) end end |
Instance Attribute Details
#base ⇒ Object
Returns the value of attribute base.
95 96 97 |
# File 'lib/ymdp/configuration/config.rb', line 95 def base @base end |
Instance Method Details
#[](key) ⇒ Object
106 107 108 |
# File 'lib/ymdp/configuration/config.rb', line 106 def [](key) @config.get(base, key) end |
#each ⇒ Object
118 119 120 121 122 |
# File 'lib/ymdp/configuration/config.rb', line 118 def each .each do |name, values| yield name, values end end |
#exists?(*args) ⇒ Boolean
110 111 112 |
# File 'lib/ymdp/configuration/config.rb', line 110 def exists?(*args) @config.exists?(base, *args) end |
#file_not_found(filename) ⇒ Object
124 125 126 127 128 129 130 |
# File 'lib/ymdp/configuration/config.rb', line 124 def file_not_found(filename) $stdout.puts $stdout.puts "Create #{filename} with the following command:\n\n ./script/config" $stdout.puts raise "File not found: #{filename}" end |
#options(*args) ⇒ Object
114 115 116 |
# File 'lib/ymdp/configuration/config.rb', line 114 def (*args) @config.get(base, *args) end |