Class: Foruiman::ANSI::Decoder
- Inherits:
-
Object
- Object
- Foruiman::ANSI::Decoder
- Defined in:
- lib/foruiman/ansi.rb
Overview
Screen controls are discarded. Output may opt into horizontal line editing controls, which it interprets before storing or displaying any records.
Instance Method Summary collapse
- #feed(bytes, eof: false) ⇒ Object
-
#initialize(line_controls: false) ⇒ Decoder
constructor
A new instance of Decoder.
Constructor Details
#initialize(line_controls: false) ⇒ Decoder
Returns a new instance of Decoder.
69 70 71 72 73 74 |
# File 'lib/foruiman/ansi.rb', line 69 def initialize(line_controls: false) @line_controls = line_controls @state = :text @escape = +"" @pending = +"".b end |
Instance Method Details
#feed(bytes, eof: false) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/foruiman/ansi.rb', line 76 def feed(bytes, eof: false) output = +"".b bytes.each_byte { |byte| consume(byte, output) } output = @pending + output @pending = +"".b unless eof length = incomplete_suffix(output) @pending = output.slice!(-length, length) if length.positive? end output.force_encoding(Encoding::UTF_8).scrub.delete("\u0080-\u009f") end |