Class: Config

Inherits:
Object show all
Defined in:
lib/RubyExt/Config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runtime, config, default) ⇒ Config

Returns a new instance of Config.



4
5
6
# File 'lib/RubyExt/Config.rb', line 4

def initialize runtime, config, default		
	@runtime, @config, @default = runtime, config, default
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



2
3
4
# File 'lib/RubyExt/Config.rb', line 2

def config
  @config
end

#defaultObject (readonly)

Returns the value of attribute default.



2
3
4
# File 'lib/RubyExt/Config.rb', line 2

def default
  @default
end

#runtimeObject (readonly)

Returns the value of attribute runtime.



2
3
4
# File 'lib/RubyExt/Config.rb', line 2

def runtime
  @runtime
end

Instance Method Details

#[](key) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/RubyExt/Config.rb', line 8

def [] key
	value = @runtime[key]
	value = @config[key] if value.equal? nil
	value = @default[key] if value.equal? nil			
	raise "There is no key #{key}!" if value.equal? nil
	return value
end

#[]=(key, value) ⇒ Object



16
17
18
# File 'lib/RubyExt/Config.rb', line 16

def []= key, value
	@runtime[key] = value
end

#include?(key) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/RubyExt/Config.rb', line 20

def include? key
	(@runtime[key] != nil) or (@config[key] != nil) or (@default[key] != nil)
end