Module: SuperDiff::Csi

Defined in:
lib/super_diff/csi.rb,
lib/super_diff/csi/color.rb,
lib/super_diff/csi/document.rb,
lib/super_diff/csi/bold_sequence.rb,
lib/super_diff/csi/four_bit_color.rb,
lib/super_diff/csi/reset_sequence.rb,
lib/super_diff/csi/eight_bit_color.rb,
lib/super_diff/csi/colorized_document.rb,
lib/super_diff/csi/color_sequence_block.rb,
lib/super_diff/csi/uncolorized_document.rb,
lib/super_diff/csi/twenty_four_bit_color.rb

Defined Under Namespace

Classes: BoldSequence, Color, ColorSequenceBlock, ColorizedDocument, Document, EightBitColor, FourBitColor, ResetSequence, TwentyFourBitColor, UncolorizedDocument

Class Method Summary collapse

Class Method Details

.already_colorized?(text) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/super_diff/csi.rb', line 25

def self.already_colorized?(text)
  text.match?(/\e\[\d+m/)
end

.decolorize(text) ⇒ Object



21
22
23
# File 'lib/super_diff/csi.rb', line 21

def self.decolorize(text)
  text.gsub(/\e\[\d+(?:;\d+)*m(.+?)\e\[0m/, '\1')
end

.reset_sequenceObject



17
18
19
# File 'lib/super_diff/csi.rb', line 17

def self.reset_sequence
  ResetSequence.new
end