Class: Sai::ANSI::StyleParser Private

Inherits:
Object
  • Object
show all
Defined in:
lib/sai/ansi/style_parser.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.

Handles parsing of ANSI style codes

Author:

Since:

  • 0.3.1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(segment) ⇒ StyleParser

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 StyleParser

Parameters:

  • segment (Hash) —

    the segment to update

Author:

Since:

  • 0.3.1



44
45
46
# File 'lib/sai/ansi/style_parser.rb', line 44

def initialize(segment)
  @segment = segment
end

Instance Attribute Details

#segment ⇒ Hash (readonly)

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.

The current segment being processed

Returns:

  • (Hash) —

    the current segment being processed

Author:

Since:

  • 0.3.1



31
32
33
# File 'lib/sai/ansi/style_parser.rb', line 31

def segment
  @segment
end

Instance Method Details

#parse(code) ⇒ void

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.

This method returns an undefined value.

Parse a style code

Parameters:

  • code (Integer) —

    the style code

Author:

Since:

  • 0.3.1



59
60
61
62
63
# File 'lib/sai/ansi/style_parser.rb', line 59

def parse(code)
  return unless code.to_s.match?(STYLE_CODE_PATTERN)

  segment[:styles] << code.to_s
end