Class: Config
- Inherits:
-
Object
- Object
- Config
- Defined in:
- lib/meshx-plugin-sdk.rb
Instance Method Summary collapse
- #get(name) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #load ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
314 315 316 317 |
# File 'lib/meshx-plugin-sdk.rb', line 314 def initialize() @config_path = Helper.get_env("X_CONFIG", "/etc/plugin/config.json") @config = load() end |
Instance Method Details
#get(name) ⇒ Object
325 326 327 328 329 330 331 332 |
# File 'lib/meshx-plugin-sdk.rb', line 325 def get(name) rtn = @config[name] if rtn == "" puts("plugin configuration is not valid, missing: #{name}") exit(2) end return rtn end |
#load ⇒ Object
319 320 321 322 323 |
# File 'lib/meshx-plugin-sdk.rb', line 319 def load() file = File.read(@config_path) config = JSON.parse(file) return config end |