Class: TempestTime::Setting
- Inherits:
-
Object
- Object
- TempestTime::Setting
show all
- Defined in:
- lib/tempest_time/setting.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Setting.
7
8
9
10
11
12
|
# File 'lib/tempest_time/setting.rb', line 7
def initialize
@config = TTY::Config.new
config.extname = '.yml'
config.append_path(directory)
Dir.mkdir(directory) unless File.exists?(directory)
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
5
6
7
|
# File 'lib/tempest_time/setting.rb', line 5
def config
@config
end
|
Instance Method Details
#append(key, value) ⇒ Object
34
35
36
|
# File 'lib/tempest_time/setting.rb', line 34
def append(key, value)
write_config { config.append(value, to: key) }
end
|
#delete(key) ⇒ Object
22
23
24
|
# File 'lib/tempest_time/setting.rb', line 22
def delete(key)
write_config { config.delete(key) }
end
|
#fetch(key) ⇒ Object
18
19
20
|
# File 'lib/tempest_time/setting.rb', line 18
def fetch(key)
read_config { config.fetch(key) }
end
|
#keys ⇒ Object
14
15
16
|
# File 'lib/tempest_time/setting.rb', line 14
def keys
read_config { config.to_h.keys }
end
|
#remove(key, value) ⇒ Object
30
31
32
|
# File 'lib/tempest_time/setting.rb', line 30
def remove(key, value)
write_config { config.remove(value, from: key) }
end
|
#set(key, value) ⇒ Object
26
27
28
|
# File 'lib/tempest_time/setting.rb', line 26
def set(key, value)
write_config { config.set(key, value: value) }
end
|