Class: Vedeu::Output::Output

Inherits:
Object
  • Object
show all
Includes:
Common
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

Methods included from Common

#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?

Constructor Details

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

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

Parameters:

  • output (String)


49
50
51
# File 'lib/vedeu/output/output.rb', line 49

def initialize(output)
  @output = output
end

Instance Attribute Details

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

Returns:



93
94
95
# File 'lib/vedeu/output/output.rb', line 93

def output
  @output
end

Class Method Details

.buffer_update(output) ⇒ Array<String>|String|NilClass

Parameters:

  • output (String)

Returns:

  • (Array<String>|String|NilClass)


19
20
21
# File 'lib/vedeu/output/output.rb', line 19

def buffer_update(output)
  new(output).buffer_update
end

.buffer_write(output) ⇒ Array<String>|String|NilClass

Parameters:

  • output (String)

Returns:

  • (Array<String>|String|NilClass)


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

def buffer_write(output)
  new(output).buffer_write
end

.direct_write(output) ⇒ Array<String>|String|NilClass

Parameters:

  • output (String)

Returns:

  • (Array<String>|String|NilClass)


31
32
33
# File 'lib/vedeu/output/output.rb', line 31

def direct_write(output)
  new(output).direct_write
end

.render_output(output) ⇒ Array<String>|String|NilClass

Parameters:

  • output (String)

Returns:

  • (Array<String>|String|NilClass)


39
40
41
# File 'lib/vedeu/output/output.rb', line 39

def render_output(output)
  new(output).render_output
end

Instance Method Details

#buffer_updateArray<String>|String|NilClass

Returns:

  • (Array<String>|String|NilClass)


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

def buffer_update
  Vedeu::Buffers::Terminal.update(output) if output?
end

#buffer_writeArray<String>|String|NilClass

Returns:

  • (Array<String>|String|NilClass)


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

def buffer_write
  Vedeu::Buffers::Terminal.write(output) if output?
end

#direct_writeArray<String>|String|NilClass

Returns:

  • (Array<String>|String|NilClass)


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

def direct_write
  Vedeu::Terminal.output(output.to_s) if output?
end

#output?Boolean (private)

Returns:



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

def output?
  present?(output)
end

#render_outputArray<String>|String|NilClass

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

Returns:

  • (Array<String>|String|NilClass)

See Also:



78
79
80
81
82
83
84
85
86
# File 'lib/vedeu/output/output.rb', line 78

def render_output
  if escape?(output)
    direct_write

  else
    buffer_write

  end
end