Class: TranscationAPI

Inherits:
Object
  • Object
show all
Extended by:
FileStorageModule
Defined in:
lib/TranscationAPI.rb

Constant Summary collapse

@@file_path =
File.join(File.dirname(caller[0]), "/FileStorage/transcations.log")

Class Method Summary collapse

Methods included from FileStorageModule

add_line, read_file, remove_line, update_line

Class Method Details

.get_listObject



21
22
23
# File 'lib/TranscationAPI.rb', line 21

def self.get_list
  @@list
end

.record(transcation) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/TranscationAPI.rb', line 13

def self.record(transcation)
  @@list ||= Array.new
  transcation[:id] = @@list.size
  @@list.push(transcation)
  puts "TranscationAPI#record: Recording a transcation with these details: #{transcation}"
  add_line(@@file_path, transcation)
end

.seedObject



9
10
11
# File 'lib/TranscationAPI.rb', line 9

def self.seed
  @@list = read_file(@@file_path)
end