Class: Vedeu::Output::Output

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

Overview

Sends the output to the renderers.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ Vedeu::Output::Output

Return a new instance of Vedeu::Output::Output.

Parameters:



55
56
57
# File 'lib/vedeu/output/output.rb', line 55

def initialize(output)
  @output = output
end

Instance Attribute Details

#outputArray<Array<Vedeu::Views::Char>>| NilClass|Vedeu::Models::Escape (readonly, protected)

Returns:



97
98
99
# File 'lib/vedeu/output/output.rb', line 97

def output
  @output
end

Class Method Details

.buffer_update(output) ⇒ Array

Parameters:

Returns:

  • (Array)


15
16
17
18
19
# File 'lib/vedeu/output/output.rb', line 15

def self.buffer_update(output)
  return nil if output.nil?

  new(output).buffer_update
end

.buffer_write(output) ⇒ Array

Parameters:

Returns:

  • (Array)


24
25
26
27
28
# File 'lib/vedeu/output/output.rb', line 24

def self.buffer_write(output)
  return nil if output.nil?

  new(output).buffer_write
end

.direct_write(output) ⇒ Array<String>

Parameters:

Returns:

  • (Array<String>)


33
34
35
36
37
# File 'lib/vedeu/output/output.rb', line 33

def self.direct_write(output)
  return nil if output.nil?

  new(output).direct_write
end

.render_output(output) ⇒ Array|NilClass|String

Writes output to the defined renderers.

Parameters:

Returns:

  • (Array|NilClass|String)


44
45
46
47
48
# File 'lib/vedeu/output/output.rb', line 44

def self.render_output(output)
  return nil if output.nil?

  new(output).render_output
end

Instance Method Details

#buffer_updateArray

Returns:

  • (Array)


60
61
62
# File 'lib/vedeu/output/output.rb', line 60

def buffer_update
  buffer_update!
end

#buffer_update!Array (private)

Returns:

  • (Array)


102
103
104
# File 'lib/vedeu/output/output.rb', line 102

def buffer_update!
  Vedeu::Terminal::Buffer.update(output)
end

#buffer_writeArray

Returns:

  • (Array)


65
66
67
# File 'lib/vedeu/output/output.rb', line 65

def buffer_write
  buffer_write!
end

#buffer_write!Array (private)

Returns:

  • (Array)


107
108
109
# File 'lib/vedeu/output/output.rb', line 107

def buffer_write!
  Vedeu::Terminal::Buffer.write(output)
end

#direct_writeArray<String>

Returns:

  • (Array<String>)


70
71
72
# File 'lib/vedeu/output/output.rb', line 70

def direct_write
  direct_write!
end

#direct_write!Array<String> (private)

Returns:

  • (Array<String>)


112
113
114
# File 'lib/vedeu/output/output.rb', line 112

def direct_write!
  Vedeu::Terminal.output(output.to_s)
end

#escape_sequence?Boolean (private)

Returns:

  • (Boolean)


117
118
119
# File 'lib/vedeu/output/output.rb', line 117

def escape_sequence?
  output.is_a?(Vedeu::Models::Escape)
end

#render_outputArray|String|NilClass

Send the view to the renderers. If the output is a Models::Escape object (typical when showing or hiding the cursor) then we bypass the Terminal::Buffer and write directly to the terminal because escape sequences only make sense to the terminal and not other renderers.

Returns:

  • (Array|String|NilClass)


82
83
84
85
86
87
88
89
90
# File 'lib/vedeu/output/output.rb', line 82

def render_output
  if escape_sequence?
    direct_write!

  else
    buffer_write!

  end
end