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

### Files

- LICENSE
- README.rdoc

### 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
- Multimap
- Multiset
- NestedMultimap

No matching classes.

# Regin::Group

### Attributes

capture[R]
expression[R]
index[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)
      @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 63
    def capture?
      capture
    end

dup(options = {}) click to toggle source

    # File lib/rack/mount/vendor/regin/regin/group.rb, line 43
    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 59
    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 23
    def literal?
      quantifier.nil? && expression.literal?
    end

match(char) click to toggle source

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

option_names() click to toggle source

    # File lib/rack/mount/vendor/regin/regin/group.rb, line 16
    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 37
    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 27
    def to_s(parent = false)
      if !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.