Class: Sai::ANSI::SequencedString::Segment
- Inherits:
-
Object
- Object
- Sai::ANSI::SequencedString::Segment
- Defined in:
- lib/sai/ansi/sequenced_string.rb
Overview
A segment of an ANSI encoded string
Defined Under Namespace
Classes: Location
Instance Attribute Summary collapse
-
#background ⇒ String?
readonly
The background color sequences for the Segment.
-
#encoded_location ⇒ Location
(also: #encoded_loc)
readonly
The Location of the encoded string within the Sai::ANSI::SequencedString.
-
#foreground ⇒ String?
readonly
The foreground color sequences for the Segment.
-
#stripped_location ⇒ Location
(also: #stripped_loc)
readonly
The Location of the encoded string without it's encoding within the Sai::ANSI::SequencedString.
-
#styles ⇒ Array<String>
readonly
The style sequences (bold, underline, etc...) for the segment.
-
#text ⇒ String
readonly
The raw text of the Segment without any of its ANSI sequences.
Instance Method Summary collapse
-
#initialize(**options) ⇒ Segment
constructor
private
Initialize a new instance of Segment.
Constructor Details
#initialize(**options) ⇒ Segment
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 Segment
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
# File 'lib/sai/ansi/sequenced_string.rb', line 408 def initialize(**) @background = .fetch(:background, nil) @foreground = .fetch(:foreground, nil) @encoded_location = Location.new( end_position: .fetch(:encoded_end), #: Integer start_position: .fetch(:encoded_start) #: Integer ) @stripped_location = Location.new( end_position: .fetch(:stripped_end), #: Integer start_position: .fetch(:stripped_start) #: Integer ) @styles = .fetch(:styles, []) @text = .fetch(:text) freeze end |
Instance Attribute Details
#background ⇒ String? (readonly)
The background color sequences for the Segment
322 323 324 |
# File 'lib/sai/ansi/sequenced_string.rb', line 322 def background @background end |
#encoded_location ⇒ Location (readonly) Also known as: encoded_loc
The Location of the encoded string within the Sai::ANSI::SequencedString
342 343 344 |
# File 'lib/sai/ansi/sequenced_string.rb', line 342 def encoded_location @encoded_location end |
#foreground ⇒ String? (readonly)
The foreground color sequences for the Segment
332 333 334 |
# File 'lib/sai/ansi/sequenced_string.rb', line 332 def foreground @foreground end |
#stripped_location ⇒ Location (readonly) Also known as: stripped_loc
The Location of the encoded string without it's encoding within the Sai::ANSI::SequencedString
353 354 355 |
# File 'lib/sai/ansi/sequenced_string.rb', line 353 def stripped_location @stripped_location end |
#styles ⇒ Array<String> (readonly)
The style sequences (bold, underline, etc...) for the segment
364 365 366 |
# File 'lib/sai/ansi/sequenced_string.rb', line 364 def styles @styles end |
#text ⇒ String (readonly)
The raw text of the Segment without any of its ANSI sequences
374 375 376 |
# File 'lib/sai/ansi/sequenced_string.rb', line 374 def text @text end |