Class: Prompt::MultiMatcher
Constant Summary
Constants inherited
from Matcher
Prompt::Matcher::SEP
Instance Attribute Summary
Attributes inherited from Matcher
#parameter
Instance Method Summary
collapse
Methods inherited from Matcher
#initialize
Instance Method Details
#matches(s) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/prompt/multi_matcher.rb', line 8
def matches s
return [""] if s.length == 0
ss = StringScanner.new(s)
r = Regexp.new "[^#{SEP}]*"
res = []
until ss.eos?
ss.scan /#{SEP}/
res << ss.scan(r)
end
res
end
|
#regex ⇒ Object
4
5
6
|
# File 'lib/prompt/multi_matcher.rb', line 4
def regex
"(?<#{parameter.name}>([^#{SEP}]*)(#{SEP}[^#{SEP}]*)*)"
end
|