Sha256: cac9bc55bc5cb58e3fd078440807d36c74ab1d09b619590fd9b78b30868f6824
Contents?: true
Size: 915 Bytes
Versions: 1
Compression:
Stored size: 915 Bytes
Contents
require 'mustermann/ast' module Mustermann # Sinatra 2.0 style pattern implementation. # # @example # Mustermann.new('/:foo') === '/bar' # => true # # @see Pattern # @see file:README.md#sinatra Syntax description in the README class Sinatra < AST def parse_element(buffer) case char = buffer.getch when nil, ?? then unexpected(char) when ?) then unexpected(char, exception: UnexpectedClosingGroup) when ?* then Splat.new when ?/ then Separator.new(char) when ?( then Group.parse { parse_buffer(buffer) } when ?: then Capture.parse { buffer.scan(/\w+/) } when ?\\ then Char.new expect(buffer, /./) else Char.new(char) end end def parse_suffix(element, buffer) return element unless buffer.scan(/\?/) Optional.new(element) end private :parse_element, :parse_suffix end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mustermann-0.0.1 | lib/mustermann/sinatra.rb |