Class: Vedeu::Renderers::File
- Inherits:
-
Object
- Object
- Vedeu::Renderers::File
- Defined in:
- lib/vedeu/output/renderers/file.rb
Overview
Converts a grid of Char objects into a stream of escape sequences and content suitable for a terminal, and writes them to a file in the /tmp directory.
Instance Attribute Summary collapse
- #output ⇒ Array<Array<Vedeu::Char>> readonly protected
Class Method Summary collapse
Instance Method Summary collapse
- #defaults ⇒ Hash private
- #filename ⇒ String private
-
#initialize(output, options = {}) ⇒ Vedeu::Renderers::File
constructor
Returns a new instance of Vedeu::Renderers::File.
- #options ⇒ Hash private
- #parsed ⇒ String private
- #path ⇒ String private
- #render ⇒ String
- #timestamp ⇒ Float private
- #timestamp? ⇒ Boolean private
Constructor Details
#initialize(output, options = {}) ⇒ Vedeu::Renderers::File
Returns a new instance of Vedeu::Renderers::File.
22 23 24 25 |
# File 'lib/vedeu/output/renderers/file.rb', line 22 def initialize(output, = {}) @output = output = end |
Instance Attribute Details
#output ⇒ Array<Array<Vedeu::Char>> (readonly, protected)
38 39 40 |
# File 'lib/vedeu/output/renderers/file.rb', line 38 def output @output end |
Class Method Details
.render(output, options = {}) ⇒ String
13 14 15 |
# File 'lib/vedeu/output/renderers/file.rb', line 13 def self.render(output, = {}) new(output, ).render end |
Instance Method Details
#defaults ⇒ Hash (private)
81 82 83 84 85 |
# File 'lib/vedeu/output/renderers/file.rb', line 81 def defaults { timestamp: false, } end |
#filename ⇒ String (private)
48 49 50 51 52 53 54 55 56 |
# File 'lib/vedeu/output/renderers/file.rb', line 48 def filename if "out_#{timestamp}" else 'out' end end |
#options ⇒ Hash (private)
76 77 78 |
# File 'lib/vedeu/output/renderers/file.rb', line 76 def defaults.merge!() end |
#parsed ⇒ String (private)
59 60 61 |
# File 'lib/vedeu/output/renderers/file.rb', line 59 def parsed @parsed ||= Vedeu::Compressor.new(output).render end |
#path ⇒ String (private)
43 44 45 |
# File 'lib/vedeu/output/renderers/file.rb', line 43 def path "/tmp/#{filename}" end |
#render ⇒ String
28 29 30 31 32 |
# File 'lib/vedeu/output/renderers/file.rb', line 28 def render ::File.open(path, 'w') { |f| f.write(parsed) } parsed end |
#timestamp ⇒ Float (private)
64 65 66 |
# File 'lib/vedeu/output/renderers/file.rb', line 64 def ||= Time.now.to_f end |
#timestamp? ⇒ Boolean (private)
69 70 71 72 73 |
# File 'lib/vedeu/output/renderers/file.rb', line 69 def return true if [:timestamp] false end |