# File lib/rack/mount/vendor/regin/regin/expression.rb, line 5
5: def initialize(*args)
6: args, options = extract_options(args)
7:
8: @multiline = @ignorecase = @extended = nil
9:
10: if args.length == 1 && args.first.instance_of?(Array)
11: super(args.first)
12: else
13: args = args.map { |e| e.instance_of?(String) ? Character.new(e) : e }
14: super(args)
15: end
16:
17: self.multiline = options[:multiline] if options.key?(:multiline)
18: self.ignorecase = options[:ignorecase] if options.key?(:ignorecase)
19: self.extended = options[:extended] if options.key?(:extended)
20: end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 61
61: def +(other)
62: ary = other.is_a?(self.class) ? other.internal_array : other
63: ary = @array + ary + [options.to_h(true)]
64: self.class.new(*ary)
65: end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 29
29: def anchored?
30: anchored_to_start? && anchored_to_end?
31: end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 37
37: def anchored_to_end?
38: last.is_a?(Anchor) && last == '\Z'
39: end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 49
49: def anchored_to_end_of_line?
50: anchored_to_end? || (last.is_a?(Anchor) && last == '$')
51: end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 41
41: def anchored_to_line?
42: anchored_to_start_of_line? && anchored_to_end_of_line?
43: end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 33
33: def anchored_to_start?
34: first.is_a?(Anchor) && first == '\A'
35: end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 45
45: def anchored_to_start_of_line?
46: anchored_to_start? || (first.is_a?(Anchor) && first == '^')
47: end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 95
95: def casefold?
96: ignorecase
97: end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 67
67: def dup(options = {})
68: expression = super()
69: expression.multiline = options[:multiline] if options.key?(:multiline)
70: expression.ignorecase = options[:ignorecase] if options.key?(:ignorecase)
71: expression.extended = options[:extended] if options.key?(:extended)
72: expression
73: end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 57
57: def flags
58: options.to_i
59: end
Returns true if expression could be treated as a literal string.
A Expression is literal if all its elements are literal.
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 25
25: def literal?
26: !ignorecase && all? { |e| e.literal? }
27: end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 53
53: def options?
54: options.any?(true)
55: end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 75
75: def to_s(parent = false)
76: if parent || !options?
77: map { |e| e.to_s(parent) }.join
78: else
79: with, without = [], []
80: multiline ? (with << 'm') : (without << 'm')
81: ignorecase ? (with << 'i') : (without << 'i')
82: extended ? (with << 'x') : (without << 'x')
83:
84: with = with.join
85: without = without.any? ? "-#{without.join}" : ''
86:
87: "(?#{with}#{without}:#{map { |e| e.to_s(true) }.join})"
88: end
89: end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 122
122: def extended=(extended)
123: @extended = extended
124: end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 115
115: def ignorecase=(ignorecase)
116: if @ignorecase.nil?
117: @array.map! { |e| e.dup(:ignorecase => ignorecase) }
118: @ignorecase = ignorecase
119: end
120: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.