Class: Vedeu::Buffer

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/support/buffer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vars) ⇒ Buffer

Returns a new instance of Buffer.



5
6
7
8
9
10
11
12
# File 'lib/vedeu/support/buffer.rb', line 5

def initialize(vars)
  @vars    = vars
  @name    = vars.fetch(:name)
  @clear   = vars.fetch(:clear)
  @current = vars.fetch(:current)
  @group   = vars.fetch(:group)
  @_next   = vars.fetch(:next)
end

Instance Attribute Details

#_nextObject (readonly)

Returns the value of attribute _next.



3
4
5
# File 'lib/vedeu/support/buffer.rb', line 3

def _next
  @_next
end

#clearObject (readonly)

Returns the value of attribute clear.



3
4
5
# File 'lib/vedeu/support/buffer.rb', line 3

def clear
  @clear
end

#currentObject (readonly)

Returns the value of attribute current.



3
4
5
# File 'lib/vedeu/support/buffer.rb', line 3

def current
  @current
end

#groupObject (readonly)

Returns the value of attribute group.



3
4
5
# File 'lib/vedeu/support/buffer.rb', line 3

def group
  @group
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/vedeu/support/buffer.rb', line 3

def name
  @name
end

Instance Method Details

#enqueue(sequence) ⇒ Object



14
15
16
# File 'lib/vedeu/support/buffer.rb', line 14

def enqueue(sequence)
  merge({ next: sequence })
end

#refreshObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vedeu/support/buffer.rb', line 18

def refresh
  sequence = if !_next.empty?
    merge({ current: _next, next: '' }).current

  elsif current.empty?
    clear

  else
    current

  end

  Terminal.output(sequence)

  self
end