Collection
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 5 def initialize(*args) args, options = extract_options(args) @multiline = @ignorecase = @extended = nil if args.length == 1 && args.first.instance_of?(Array) super(args.first) else args = args.map { |e| e.instance_of?(String) ? Character.new(e) : e } super(args) end self.multiline = options[:multiline] if options.key?(:multiline) self.ignorecase = options[:ignorecase] if options.key?(:ignorecase) self.extended = options[:extended] if options.key?(:extended) end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 61 def +(other) ary = other.is_a?(self.class) ? other.internal_array : other ary = @array + ary + [options.to_h(true)] self.class.new(*ary) end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 29 def anchored? anchored_to_start? && anchored_to_end? end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 37 def anchored_to_end? last.is_a?(Anchor) && last == '\Z' end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 49 def anchored_to_end_of_line? anchored_to_end? || (last.is_a?(Anchor) && last == '$') end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 41 def anchored_to_line? anchored_to_start_of_line? && anchored_to_end_of_line? end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 33 def anchored_to_start? first.is_a?(Anchor) && first == '\A' end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 45 def anchored_to_start_of_line? anchored_to_start? || (first.is_a?(Anchor) && first == '^') end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 95 def casefold? ignorecase end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 67 def dup(options = {}) expression = super() expression.multiline = options[:multiline] if options.key?(:multiline) expression.ignorecase = options[:ignorecase] if options.key?(:ignorecase) expression.extended = options[:extended] if options.key?(:extended) expression end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 57 def flags options.to_i 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 def literal? !ignorecase && all? { |e| e.literal? } end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 53 def options? options.any?(true) end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 75 def to_s(parent = false) if parent || !options? map { |e| e.to_s(parent) }.join else with, without = [], [] multiline ? (with << 'm') : (without << 'm') ignorecase ? (with << 'i') : (without << 'i') extended ? (with << 'x') : (without << 'x') with = with.join without = without.any? ? "-#{without.join}" : '' "(?#{with}#{without}:#{map { |e| e.to_s(true) }.join})" end end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 122 def extended=(extended) @extended = extended end
# File lib/rack/mount/vendor/regin/regin/expression.rb, line 115 def ignorecase=(ignorecase) if @ignorecase.nil? @array.map! { |e| e.dup(:ignorecase => ignorecase) } @ignorecase = ignorecase end end
Generated with the Darkfish Rdoc Generator 2.