Class: TarkaMatchers::Helpers::SGR::StyledCapture

Inherits:
Object
  • Object
show all
Defined in:
lib/tarka_matchers/helpers/string/sgr/styled_capture.rb

Constant Summary collapse

STYLED =
/\\e\[\d{1,3}m\K(?!\\e\[\d{1,3}m)(.+?)(?=\\e\[\d{1,3}m|$)/
CODE =
/\\e\[\K\d{1,3}(?=m)/

Class Method Summary collapse

Class Method Details

.capture(string, number) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/tarka_matchers/helpers/string/sgr/styled_capture.rb', line 16

def self.capture string, number
	#[]
	#puts string
	string = escape(string)
	#puts '##################################'
	puts self.indexes_of( string, /ab/)
	#puts '##################################'
	#.scan(CODE).uniq
end

.indexes_of(string, regex) ⇒ Object



9
10
11
12
13
14
# File 'lib/tarka_matchers/helpers/string/sgr/styled_capture.rb', line 9

def self.indexes_of string, regex
	string.to_enum(:scan,regex).map do |v,|
		si = $`.size
		[si, v, si + v.length - 1]
	end
end