Object
# File lib/rack/mount/vendor/regin/regin/group.rb, line 5 def initialize(expression, options = {}) @quantifier = @index = @name = nil @capture = true @expression = expression.dup(options) @quantifier = options[:quantifier] if options.key?(:quantifier) @lookahead = options[:lookahead] if options.key?(:lookahead) @capture = options[:capture] if options.key?(:capture) @index = options[:index] if options.key?(:index) @name = options[:name] if options.key?(:name) end
# File lib/rack/mount/vendor/regin/regin/group.rb, line 68 def capture? capture end
# File lib/rack/mount/vendor/regin/regin/group.rb, line 48 def dup(options = {}) original_options = option_names.inject({}) do |h, m| h[m.to_sym] = send(m) h end self.class.new(expression, original_options.merge(options)) end
# File lib/rack/mount/vendor/regin/regin/group.rb, line 64 def include?(char) expression.include?(char) end
Returns true if expression could be treated as a literal string.
A Group is literal if its expression is literal and it has no quantifier.
# File lib/rack/mount/vendor/regin/regin/group.rb, line 24 def literal? quantifier.nil? && lookahead.nil? && expression.literal? end
# File lib/rack/mount/vendor/regin/regin/group.rb, line 60 def match(char) to_regexp.match(char) end
# File lib/rack/mount/vendor/regin/regin/group.rb, line 17 def option_names %( quantifier capture index name ) end
# File lib/rack/mount/vendor/regin/regin/group.rb, line 42 def to_regexp(anchored = false) re = to_s re = "\\A#{re}\\Z" if anchored Regexp.compile(re) end
# File lib/rack/mount/vendor/regin/regin/group.rb, line 28 def to_s(parent = false) if lookahead == :postive "(?=#{expression.to_s(parent)})#{quantifier}" elsif lookahead == :negative "(?!#{expression.to_s(parent)})#{quantifier}" elsif !expression.options? "(#{capture ? '' : '?:'}#{expression.to_s(parent)})#{quantifier}" elsif capture == false "#{expression.to_s}#{quantifier}" else "(#{expression.to_s})#{quantifier}" end end
Generated with the Darkfish Rdoc Generator 2.