Class: Vedeu::Output::Output
- Inherits:
-
Object
- Object
- Vedeu::Output::Output
- Defined in:
- lib/vedeu/output/output.rb
Overview
Sends the output to the renderers.
Instance Attribute Summary collapse
- #output ⇒ Array<Array<Vedeu::Views::Char>>| NilClass|Vedeu::Models::Escape readonly protected
Class Method Summary collapse
- .buffer_update(output) ⇒ Array
- .buffer_write(output) ⇒ Array
- .direct_write(output) ⇒ Array<String>
-
.render_output(output) ⇒ Array|NilClass|String
Writes output to the defined renderers.
Instance Method Summary collapse
- #buffer_update ⇒ Array
- #buffer_update! ⇒ Array private
- #buffer_write ⇒ Array
- #buffer_write! ⇒ Array private
- #direct_write ⇒ Array<String>
- #direct_write! ⇒ Array<String> private
- #escape_sequence? ⇒ Boolean private
-
#initialize(output) ⇒ Vedeu::Output::Output
constructor
Return a new instance of Vedeu::Output::Output.
-
#render_output ⇒ Array|String|NilClass
Send the view to the renderers.
Constructor Details
#initialize(output) ⇒ Vedeu::Output::Output
Return a new instance of Vedeu::Output::Output.
55 56 57 |
# File 'lib/vedeu/output/output.rb', line 55 def initialize(output) @output = output end |
Instance Attribute Details
#output ⇒ Array<Array<Vedeu::Views::Char>>| NilClass|Vedeu::Models::Escape (readonly, protected)
97 98 99 |
# File 'lib/vedeu/output/output.rb', line 97 def output @output end |
Class Method Details
.buffer_update(output) ⇒ 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
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>
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.
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_update ⇒ Array
60 61 62 |
# File 'lib/vedeu/output/output.rb', line 60 def buffer_update buffer_update! end |
#buffer_update! ⇒ Array (private)
102 103 104 |
# File 'lib/vedeu/output/output.rb', line 102 def buffer_update! Vedeu::Terminal::Buffer.update(output) end |
#buffer_write ⇒ Array
65 66 67 |
# File 'lib/vedeu/output/output.rb', line 65 def buffer_write buffer_write! end |
#buffer_write! ⇒ Array (private)
107 108 109 |
# File 'lib/vedeu/output/output.rb', line 107 def buffer_write! Vedeu::Terminal::Buffer.write(output) end |
#direct_write ⇒ Array<String>
70 71 72 |
# File 'lib/vedeu/output/output.rb', line 70 def direct_write direct_write! end |
#direct_write! ⇒ Array<String> (private)
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)
117 118 119 |
# File 'lib/vedeu/output/output.rb', line 117 def escape_sequence? output.is_a?(Vedeu::Models::Escape) end |
#render_output ⇒ Array|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.
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 |