Class: Sai::ANSI::SequenceProcessor Private
- Inherits:
-
Object
- Object
- Sai::ANSI::SequenceProcessor
- Defined in:
- lib/sai/ansi/sequence_processor.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Extract ANSI sequence information from a string
Class Method Summary collapse
-
.process(string) ⇒ Array<Hash{Symbol => Object}>
private
Initialize a new instance of SequenceProcessor and parse the provided string.
Instance Method Summary collapse
-
#initialize(string) ⇒ SequenceProcessor
constructor
private
Initialize a new instance of SequenceProcessor.
-
#process ⇒ Array<Hash{Symbol => Object}>
private
Parse a string and return a hash of segments.
Constructor Details
#initialize(string) ⇒ SequenceProcessor
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize a new instance of SequenceProcessor
54 55 56 57 58 59 60 61 62 |
# File 'lib/sai/ansi/sequence_processor.rb', line 54 def initialize(string) @scanner = StringScanner.new(string) @segments = [] @current_segment = { text: +'', foreground: nil, background: nil, styles: [] } @encoded_pos = 0 @stripped_pos = 0 @color_parser = ColorParser.new(@current_segment) @style_parser = StyleParser.new(@current_segment) end |
Class Method Details
.process(string) ⇒ Array<Hash{Symbol => Object}>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize a new instance of SequenceProcessor and parse the provided string
39 40 41 |
# File 'lib/sai/ansi/sequence_processor.rb', line 39 def self.process(string) new(string).process end |
Instance Method Details
#process ⇒ Array<Hash{Symbol => Object}>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Parse a string and return a hash of segments
73 74 75 76 77 78 |
# File 'lib/sai/ansi/sequence_processor.rb', line 73 def process consume_tokens finalize_segment_if_text! @segments end |