Class: Vedeu::Buffer
- Inherits:
-
Object
- Object
- Vedeu::Buffer
- Defined in:
- lib/vedeu/support/buffer.rb
Instance Attribute Summary collapse
-
#back ⇒ Object
readonly
Returns the value of attribute back.
-
#front ⇒ Object
readonly
Returns the value of attribute front.
-
#interface ⇒ Object
readonly
Returns the value of attribute interface.
Instance Method Summary collapse
- #clear ⇒ Buffer
- #content_available? ⇒ TrueClass|FalseClass private private
- #enqueue(view) ⇒ Buffer
- #initialize(attributes = {}) ⇒ Buffer constructor
- #merge(new_attributes) ⇒ Buffer private private
- #no_content_available? ⇒ TrueClass|FalseClass private private
- #refresh ⇒ Buffer
- #render ⇒ Buffer
Constructor Details
#initialize(attributes = {}) ⇒ Buffer
12 13 14 15 16 17 18 |
# File 'lib/vedeu/support/buffer.rb', line 12 def initialize(attributes = {}) @attributes = attributes @back = attributes.fetch(:back) @front = attributes.fetch(:front) @interface = attributes.fetch(:interface) end |
Instance Attribute Details
#back ⇒ Object (readonly)
Returns the value of attribute back.
4 5 6 |
# File 'lib/vedeu/support/buffer.rb', line 4 def back @back end |
#front ⇒ Object (readonly)
Returns the value of attribute front.
4 5 6 |
# File 'lib/vedeu/support/buffer.rb', line 4 def front @front end |
#interface ⇒ Object (readonly)
Returns the value of attribute interface.
4 5 6 |
# File 'lib/vedeu/support/buffer.rb', line 4 def interface @interface end |
Instance Method Details
#clear ⇒ Buffer
41 42 43 44 45 |
# File 'lib/vedeu/support/buffer.rb', line 41 def clear Terminal.output(interface.clear) self end |
#content_available? ⇒ TrueClass|FalseClass (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
58 59 60 |
# File 'lib/vedeu/support/buffer.rb', line 58 def content_available? !!(back) end |
#enqueue(view) ⇒ Buffer
22 23 24 |
# File 'lib/vedeu/support/buffer.rb', line 22 def enqueue(view) merge({ back: view }) end |
#merge(new_attributes) ⇒ Buffer (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
52 53 54 |
# File 'lib/vedeu/support/buffer.rb', line 52 def merge(new_attributes) Buffer.new(@attributes.merge(new_attributes)) end |
#no_content_available? ⇒ TrueClass|FalseClass (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
64 65 66 |
# File 'lib/vedeu/support/buffer.rb', line 64 def no_content_available? front.nil? end |
#refresh ⇒ Buffer
27 28 29 30 31 |
# File 'lib/vedeu/support/buffer.rb', line 27 def refresh return merge({ front: back, back: nil }).render if content_available? return clear if no_content_available? return render end |
#render ⇒ Buffer
34 35 36 37 38 |
# File 'lib/vedeu/support/buffer.rb', line 34 def render Terminal.output(front.to_s) self end |