module Faye::Grammar

Constants

ALPHA
ALPHANUM
CHANNEL_NAME
CHANNEL_PATTERN
CHANNEL_SEGMENT
CHANNEL_SEGMENTS
CLIENT_ID
DIGIT
ERROR
ERROR_ARGS
ERROR_CODE
ERROR_MESSAGE
ID
INTEGER
LOWALPHA
MARK
STRING
TOKEN
UPALPHA
VERSION
VERSION_ELEMENT
WILD_CARD

Public Class Methods

choice(*list) click to toggle source
# File lib/faye/protocol/grammar.rb, line 9
def self.choice(*list)
  '(' + list.map(&method(:string)) * '|' + ')'
end
oneormore(*pattern) click to toggle source
# File lib/faye/protocol/grammar.rb, line 17
def self.oneormore(*pattern)
  '(' + string(pattern) + ')+'
end
repeat(*pattern) click to toggle source
# File lib/faye/protocol/grammar.rb, line 13
def self.repeat(*pattern)
  '(' + string(pattern) + ')*'
end
rule(&block) click to toggle source
# File lib/faye/protocol/grammar.rb, line 4
def self.rule(&block)
  source = instance_eval(&block)
  %r{^#{string(source)}$}
end
string(item) click to toggle source
# File lib/faye/protocol/grammar.rb, line 21
def self.string(item)
  return item.map(&method(:string)) * '' if Array === item
  String === item ? item : item.source.gsub(/^\^/, '').gsub(/\$$/, '')
end