lib/vedeu/buffers/virtual_buffers.rb in vedeu-0.6.8 vs lib/vedeu/buffers/virtual_buffers.rb in vedeu-0.6.9

- old
+ new

@@ -1,71 +1,77 @@ module Vedeu - # Store and retrieve {Vedeu::VirtualBuffer} objects. - # - # Each {Vedeu::VirtualBuffer} object is a copy of the current terminal - # including content but not as String objects but {Vedeu::Views::Char} - # objects. Using {Vedeu::Views::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 {Vedeu::Views::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 {Vedeu::Views::Char} in multiple ways (e.g. HTML) or in - # multiple formats (e.g. JSON), and render/use that in an appropriate way. - # - module VirtualBuffers + module Buffers - extend self - - # Fetch the oldest stored virtual buffer first. + # Store and retrieve {Vedeu::Buffers::VirtualBuffer} objects. # - # @return [Array<Array<Vedeu::Views::Char>>|NilClass] - def retrieve - Vedeu.log(type: :drb, message: 'Retrieving output') + # Each {Vedeu::Buffers::VirtualBuffer} object is a copy of the + # current terminal including content but not as String objects but + # {Vedeu::Views::Char} objects. Using {Vedeu::Views::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 {Vedeu::Views::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 + # {Vedeu::Views::Char} in multiple ways (e.g. HTML) or in multiple + # formats (e.g. JSON), and render/use that in an appropriate way. + # + module VirtualBuffers - storage.pop - end + extend self - # Store a new virtual buffer. - # - # @return [Array<Array<Vedeu::Views::Char>>] - def store(data) - Vedeu.log(type: :drb, message: 'Storing output') + # Fetch the oldest stored virtual buffer first. + # + # @return [Array<Array<Vedeu::Views::Char>>|NilClass] + def retrieve + Vedeu.log(type: :drb, message: 'Retrieving output') - storage.unshift(data) - end + storage.pop + end - # Return the number of virtual buffers currently stored. - # - # @return [Fixnum] - def size - storage.size - end + # Store a new virtual buffer. + # + # @return [Array<Array<Vedeu::Views::Char>>] + def store(data) + Vedeu.log(type: :drb, message: 'Storing output') - # Destroy all virtual buffers currently stored. - # - # @return [Array] - def clear - @storage = in_memory - end - alias_method :reset, :clear + storage.unshift(data) + end - private + # Return the number of virtual buffers currently stored. + # + # @return [Fixnum] + def size + storage.size + end - # Access to the storage for this repository. - # - # @return [Array] - def storage - @storage ||= in_memory - end + # Destroy all virtual buffers currently stored. + # + # @return [Array] + def clear + @storage = in_memory + end + alias_method :reset, :clear - # Returns an empty collection ready for the storing of virtual buffers. - # - # @return [Array] - def in_memory - [] - end + private - end # VirtualBuffers + # Access to the storage for this repository. + # + # @return [Array] + def storage + @storage ||= in_memory + end + + # Returns an empty collection ready for the storing of virtual + # buffers. + # + # @return [Array] + def in_memory + [] + end + + end # VirtualBuffers + + end # Buffers end # Vedeu