Class: Regin::Group

### Home Classes Methods

### In Files

- lib/rack/mount/vendor/regin/regin/group.rb

### Parent

Object

### Methods

- ::new
- #capture?
- #dup
- #include?
- #literal?
- #match
- #option_names
- #to_regexp
- #to_s

### Class/Module Index

Quicksearch

- Rack
- Rack::Mount
- Rack::Mount::Analysis
- Rack::Mount::Analysis::Splitting
- Rack::Mount::Analysis::Splitting::Key
- Rack::Mount::GeneratableRegexp
- Rack::Mount::GeneratableRegexp::InstanceMethods
- Rack::Mount::RegexpWithNamedGroups
- Rack::Mount::Route
- Rack::Mount::RouteSet
- Rack::Mount::RoutingError
- Rack::Mount::Strexp
- Rack::Mount::StrexpParser
- Rack::Mount::StrexpParser::ScanError
- Rack::Mount::Utils
- Regin
- Regin::Alternation
- Regin::Anchor
- Regin::Atom
- Regin::Character
- Regin::CharacterClass
- Regin::Collection
- Regin::Expression
- Regin::Group
- Regin::Options
- Regin::Parser
- Regin::Parser::ScanError

No matching classes.

# Regin::Group

### Attributes

capture[R]
expression[R]
index[R]
lookahead[R]
name[R]
quantifier[R]

### Public Class Methods

new(expression, options = {}) click to toggle source

    # 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

### Public Instance Methods

capture?() click to toggle source

    # File lib/rack/mount/vendor/regin/regin/group.rb, line 68
    def capture?
      capture
    end

dup(options = {}) click to toggle source

    # 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

include?(char) click to toggle source

    # File lib/rack/mount/vendor/regin/regin/group.rb, line 64
    def include?(char)
      expression.include?(char)
    end

literal?() click to toggle source

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

match(char) click to toggle source

    # File lib/rack/mount/vendor/regin/regin/group.rb, line 60
    def match(char)
      to_regexp.match(char)
    end

option_names() click to toggle source

    # File lib/rack/mount/vendor/regin/regin/group.rb, line 17
    def option_names
      %( quantifier capture index name )
    end

to_regexp(anchored = false) click to toggle source

    # 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

to_s(parent = false) click to toggle source

    # 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.