Sha256: ba2d8526af265e06d55b721434221b95a40f852e285cb5c2f09fe41a414240a6
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
module Vedeu class Buffer attr_reader :back, :front, :interface # @param [Hash] attributes The buffer attributes. # @option attributes :back [Hash] The next view to be rendered. # @option attributes :front [Hash] The view which is currently on screen. # @option attributes :interface [Hash] An attribute form of the interface from # which we can create a new front or back. # @return [Buffer] def initialize(attributes = {}) @attributes = attributes @back = attributes.fetch(:back) @front = attributes.fetch(:front) @interface = attributes.fetch(:interface) end # @param view [Interface] # @return [Buffer] def enqueue(view) merge({ back: view }) end # @return [Buffer] def refresh return merge({ front: back, back: nil }).render if content_available? return clear if no_content_available? return render end # @return [Buffer] def render Terminal.output(front.to_s) self end # @return [Buffer] def clear Terminal.output(interface.clear) self end private # @api private # @param new_attributes [Hash] # @return [Buffer] def merge(new_attributes) Buffer.new(@attributes.merge(new_attributes)) end # @api private # @return [TrueClass|FalseClass] def content_available? !!(back) end # @api private # @return [TrueClass|FalseClass] def no_content_available? front.nil? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.1.18 | lib/vedeu/support/buffer.rb |