Class: RegexpTree::Rep
Constant Summary
Constants inherited
from RegexpTree
EmptySequence, EmptySet
Instance Method Summary
collapse
Methods inherited from RegexpTree
#*, #+, alt, backref, charclass, #closure, #empty_sequence?, #empty_set?, #group, inherited, #inspect, linebeg, lineend, #lookahead, #negative_lookahead, non_word_boundary, #nongreedy_closure, #nongreedy_ntimes, #nongreedy_optional, #nongreedy_positive_closure, #nongreedy_rep, #ntimes, #optional, #paren, #parenthesize, #positive_closure, #pretty_print, previous_match, #regexp, #rep, rep, seq, str, strbeg, strend, strlineend, #to_s, word_boundary, #|
Constructor Details
#initialize(r, m = 0, n = nil, greedy = true) ⇒ Rep
Returns a new instance of Rep.
291
292
293
294
295
296
|
# File 'lib/regexptree.rb', line 291
def initialize(r, m=0, n=nil, greedy=true)
@r = r
@m = m
@n = n
@greedy = greedy
end
|
Instance Method Details
#case_insensitive? ⇒ Boolean
298
299
300
|
# File 'lib/regexptree.rb', line 298
def case_insensitive?
@r.case_insensitive?
end
|
#downcase ⇒ Object
306
307
308
|
# File 'lib/regexptree.rb', line 306
def downcase
Rep.new(@r.downcase, @m, @n, @greedy)
end
|
#multiline_insensitive? ⇒ Boolean
302
303
304
|
# File 'lib/regexptree.rb', line 302
def multiline_insensitive?
@r.multiline_insensitive?
end
|
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
|
# File 'lib/regexptree.rb', line 310
def pretty_format(out)
@r.parenthesize(Elt).pretty_format(out)
case @m
when 0
case @n
when 0
out.text '{0}'
when 1
out.text '?'
when nil
out.text '*'
else
out.text "{#{@m},#{@n}}"
end
when 1
case @n
when 1
when nil
out.text '+'
else
out.text "{#{@m},#{@n}}"
end
else
if @m == @n
out.text "{#{@m}}"
else
out.text "{#{@m},#{@n}}"
end
end
out.text '?' unless @greedy
end
|