Class: Sessel::IO
- Inherits:
-
Object
- Object
- Sessel::IO
- Defined in:
- lib/sessel/io.rb
Class Method Summary collapse
- .announce ⇒ Object
- .append_configuration_set_to_file(configuration_set) ⇒ Object
- .append_receipt_rule_to_file(receipt_rule) ⇒ Object
- .read_config_from_file ⇒ Object
Class Method Details
.announce ⇒ Object
5 6 7 8 9 10 |
# File 'lib/sessel/io.rb', line 5 def self.announce() puts 'Question:' ret = yield puts "Answer: #{ret}\n\n" return ret end |
.append_configuration_set_to_file(configuration_set) ⇒ Object
32 33 34 35 36 |
# File 'lib/sessel/io.rb', line 32 def self.append_configuration_set_to_file(configuration_set) config = read_config_from_file config[:configuration_sets].push(configuration_set) File.open(SESSEL_YAML, 'w') { |file| file.write(config.to_yaml) } end |
.append_receipt_rule_to_file(receipt_rule) ⇒ Object
26 27 28 29 30 |
# File 'lib/sessel/io.rb', line 26 def self.append_receipt_rule_to_file(receipt_rule) config = read_config_from_file config[:receipt_rules].push(receipt_rule) File.open(SESSEL_YAML, 'w') { |file| file.write(config.to_yaml) } end |
.read_config_from_file ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sessel/io.rb', line 12 def self.read_config_from_file() config = {} if File.file?(SESSEL_YAML) then config = YAML.load File.read(SESSEL_YAML); end unless config[:receipt_rules] then config[:receipt_rules] = [] end unless config[:configuration_sets] then config[:configuration_sets] = [] end return config end |