Class: Riser::Test::CallRecorder
- Inherits:
-
Object
- Object
- Riser::Test::CallRecorder
- Defined in:
- lib/riser/test.rb
Instance Method Summary collapse
- #call(record) ⇒ Object
- #dispose ⇒ Object
- #get_file_records ⇒ Object
- #get_memory_records ⇒ Object
-
#initialize(store_path) ⇒ CallRecorder
constructor
A new instance of CallRecorder.
Constructor Details
#initialize(store_path) ⇒ CallRecorder
Returns a new instance of CallRecorder.
8 9 10 11 |
# File 'lib/riser/test.rb', line 8 def initialize(store_path) @memory_records = [] @file_records = store_path end |
Instance Method Details
#call(record) ⇒ Object
13 14 15 16 17 |
# File 'lib/riser/test.rb', line 13 def call(record) @memory_records << record IO.write(@file_records, record + "\n", mode: 'a') self end |
#dispose ⇒ Object
31 32 33 34 |
# File 'lib/riser/test.rb', line 31 def dispose @memory_records.clear FileUtils.rm_f(@file_records) end |
#get_file_records ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/riser/test.rb', line 23 def get_file_records if (File.exist? @file_records) then IO.readlines(@file_records).map{|line| line.chomp } else [] end end |
#get_memory_records ⇒ Object
19 20 21 |
# File 'lib/riser/test.rb', line 19 def get_memory_records @memory_records end |