Module: Vedeu::VirtualBuffer
- Extended by:
- VirtualBuffer
- Included in:
- VirtualBuffer
- Defined in:
- lib/vedeu/output/virtual_buffer.rb
Overview
Store and retrieve VirtualTerminal objects.
Each VirtualTerminal object is a copy of the current terminal including content but not as String objects but Char objects. Using Char objects means that we can store the data used to make up the displayed character, complete with its colour, position and style.
Once a Char has been converted to a String, it is tricky to separate the escape sequences and string data. By deferring this conversion we can display the Char in multiple ways (e.g. HTML) or in multiple formats (e.g. JSON), and render/use that in an appropriate way.
Class Method Summary collapse
-
.clear ⇒ Array
(also: #reset)
Destroy all virtual buffers currently stored.
-
.in_memory ⇒ Array
private
Returns an empty collection ready for the storing of virtual buffers.
-
.retrieve ⇒ Array<Array<Vedeu::Char>>|NilClass
Fetch the oldest stored virtual buffer first.
-
.size ⇒ Fixnum
Return the number of virtual buffers currently stored.
-
.storage ⇒ Array
private
Access to the storage for this repository.
-
.store(data) ⇒ Array<Array<Vedeu::Char>>
Store a new virtual buffer.
Instance Method Summary collapse
-
#clear ⇒ Array
(also: #reset)
Destroy all virtual buffers currently stored.
-
#in_memory ⇒ Array
private
Returns an empty collection ready for the storing of virtual buffers.
-
#retrieve ⇒ Array<Array<Vedeu::Char>>|NilClass
Fetch the oldest stored virtual buffer first.
-
#size ⇒ Fixnum
Return the number of virtual buffers currently stored.
-
#storage ⇒ Array
private
Access to the storage for this repository.
-
#store(data) ⇒ Array<Array<Vedeu::Char>>
Store a new virtual buffer.
Class Method Details
.clear ⇒ Array Also known as: reset
Destroy all virtual buffers currently stored.
43 44 45 |
# File 'lib/vedeu/output/virtual_buffer.rb', line 43 def clear @storage = in_memory end |
.in_memory ⇒ Array (private)
Returns an empty collection ready for the storing of virtual buffers.
60 61 62 |
# File 'lib/vedeu/output/virtual_buffer.rb', line 60 def in_memory [] end |
.retrieve ⇒ Array<Array<Vedeu::Char>>|NilClass
Fetch the oldest stored virtual buffer first.
22 23 24 |
# File 'lib/vedeu/output/virtual_buffer.rb', line 22 def retrieve storage.pop end |
.size ⇒ Fixnum
Return the number of virtual buffers currently stored.
36 37 38 |
# File 'lib/vedeu/output/virtual_buffer.rb', line 36 def size storage.size end |
.storage ⇒ Array (private)
Access to the storage for this repository.
53 54 55 |
# File 'lib/vedeu/output/virtual_buffer.rb', line 53 def storage @storage ||= in_memory end |
.store(data) ⇒ Array<Array<Vedeu::Char>>
Store a new virtual buffer.
29 30 31 |
# File 'lib/vedeu/output/virtual_buffer.rb', line 29 def store(data) storage.unshift(data) end |
Instance Method Details
#clear ⇒ Array Also known as: reset
Destroy all virtual buffers currently stored.
43 44 45 |
# File 'lib/vedeu/output/virtual_buffer.rb', line 43 def clear @storage = in_memory end |
#in_memory ⇒ Array (private)
Returns an empty collection ready for the storing of virtual buffers.
60 61 62 |
# File 'lib/vedeu/output/virtual_buffer.rb', line 60 def in_memory [] end |
#retrieve ⇒ Array<Array<Vedeu::Char>>|NilClass
Fetch the oldest stored virtual buffer first.
22 23 24 |
# File 'lib/vedeu/output/virtual_buffer.rb', line 22 def retrieve storage.pop end |
#size ⇒ Fixnum
Return the number of virtual buffers currently stored.
36 37 38 |
# File 'lib/vedeu/output/virtual_buffer.rb', line 36 def size storage.size end |
#storage ⇒ Array (private)
Access to the storage for this repository.
53 54 55 |
# File 'lib/vedeu/output/virtual_buffer.rb', line 53 def storage @storage ||= in_memory end |
#store(data) ⇒ Array<Array<Vedeu::Char>>
Store a new virtual buffer.
29 30 31 |
# File 'lib/vedeu/output/virtual_buffer.rb', line 29 def store(data) storage.unshift(data) end |