Class: Jarbs::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/jarbs/config.rb

Constant Summary collapse

FILE_NAME =
'.jarbs'

Instance Method Summary collapse

Constructor Details

#initialize(file = FILE_NAME) ⇒ Config

Returns a new instance of Config.



5
6
7
8
# File 'lib/jarbs/config.rb', line 5

def initialize(file=FILE_NAME)
  @file = file
  @config = read
end

Instance Method Details

#get(key, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/jarbs/config.rb', line 15

def get(key, &block)
  val = @config[key]

  if !val && block_given?
    val = yield
    set(key, val)
  end

  val
end

#set(key, value) ⇒ Object



10
11
12
13
# File 'lib/jarbs/config.rb', line 10

def set(key, value)
  @config[key] = value
  finalize
end