Class: WebRobots::RobotsTxt::AccessControlLine

### Home Classes Methods

### In Files

- lib/webrobots/robotstxt.rb

### Parent

WebRobots::RobotsTxt::Line

### Methods

- #compile
- #match?

### Files

- LICENSE.txt
- README.rdoc

### Class/Module Index

Quicksearch

- WebRobots
- WebRobots::Error
- WebRobots::ParseError
- WebRobots::RobotsTxt
- WebRobots::RobotsTxt::AccessControlLine
- WebRobots::RobotsTxt::AgentLine
- WebRobots::RobotsTxt::AllowLine
- WebRobots::RobotsTxt::CrawlDelayLine
- WebRobots::RobotsTxt::DisallowLine
- WebRobots::RobotsTxt::ExtentionLine
- WebRobots::RobotsTxt::Line
- WebRobots::RobotsTxt::Parser
- WebRobots::RobotsTxt::Record
- Nokogiri
- Nokogiri::HTML
- Nokogiri::HTML::Document
- Webrobots

No matching classes.

# WebRobots::RobotsTxt::AccessControlLine

### Public Instance Methods

compile() click to toggle source

    # File lib/webrobots/robotstxt.rb, line 687
    def compile
      @empty = @value.empty?
      re_src = '\A'
      s = StringScanner.new(@value)
      until s.eos?
        if t = s.scan(/[^%*$]+/)
          re_src << Regexp.quote(t)
        elsif t = s.scan(/%([0-9a-f]{2})/)
          c = s[1].to_i(16)
          if c == 0x2f
            re_src << '%2[fF]'
          else
            re_src << Regexp.quote('%c' % c)
          end
        elsif t = s.scan(/\*/)
          re_src << '.*'
        elsif t = s.scan(/\$/)
          re_src << '\z'
          break
        else
          re_src << Regexp.quote(s.scan(/./))
        end
      end
      @pattern = Regexp.new(re_src, Regexp::MULTILINE)
      self
    end

match?(request_uri) click to toggle source

    # File lib/webrobots/robotstxt.rb, line 714
    def match?(request_uri)
      return false if @empty
      transformed = request_uri.gsub(/(%2[fF])|%([0-9a-f]{2})/) { $1 || '%c' % $2.to_i(16) }
      !!@pattern.match(transformed)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.