Class: URITemplate::RFC6570::RegexBuilder
- Inherits:
-
Object
- Object
- URITemplate::RFC6570::RegexBuilder
- Defined in:
- lib/uri_template/rfc6570/regex_builder.rb
Instance Method Summary (collapse)
- - (Object) <<(arg)
- - (Object) capture(&block)
- - (Object) character_class(max_length = 0, min = 0)
- - (Object) character_class_with_comma(max_length = 0, min = 0)
- - (Object) escaped_pair_connector
- - (Object) escaped_prefix
- - (Object) escaped_separator
- - (Object) group(capture = false)
-
- (RegexBuilder) initialize(expression_class)
constructor
A new instance of RegexBuilder.
- - (Object) join
- - (Object) length(*args)
- - (Object) lookahead
- - (Object) negative_lookahead
- - (Object) push(*args)
- - (Object) reluctant
- - (Object) separated_list(first = true, length = 0, min = 1, &block)
Constructor Details
- (RegexBuilder) initialize(expression_class)
A new instance of RegexBuilder
24 25 26 27 |
# File 'lib/uri_template/rfc6570/regex_builder.rb', line 24 def initialize(expression_class) @expression_class = expression_class @source = [] end |
Instance Method Details
- (Object) <<(arg)
29 30 31 32 |
# File 'lib/uri_template/rfc6570/regex_builder.rb', line 29 def <<(arg) @source << arg self end |
- (Object) capture(&block)
90 91 92 |
# File 'lib/uri_template/rfc6570/regex_builder.rb', line 90 def capture(&block) group(true, &block) end |
- (Object) character_class(max_length = 0, min = 0)
63 64 65 |
# File 'lib/uri_template/rfc6570/regex_builder.rb', line 63 def character_class(max_length=0, min = 0) self << @expression_class::CHARACTER_CLASS[:class] << format_length(max_length, min) end |
- (Object) character_class_with_comma(max_length = 0, min = 0)
59 60 61 |
# File 'lib/uri_template/rfc6570/regex_builder.rb', line 59 def character_class_with_comma(max_length=0, min = 0) self << @expression_class::CHARACTER_CLASS[:class_with_comma] << format_length(max_length, min) end |
- (Object) escaped_pair_connector
39 40 41 |
# File 'lib/uri_template/rfc6570/regex_builder.rb', line 39 def escaped_pair_connector self << Regexp.escape(@expression_class::PAIR_CONNECTOR) end |
- (Object) escaped_prefix
47 48 49 |
# File 'lib/uri_template/rfc6570/regex_builder.rb', line 47 def escaped_prefix self << Regexp.escape(@expression_class::PREFIX) end |
- (Object) escaped_separator
43 44 45 |
# File 'lib/uri_template/rfc6570/regex_builder.rb', line 43 def escaped_separator self << Regexp.escape(@expression_class::SEPARATOR) end |
- (Object) group(capture = false)
71 72 73 74 75 76 |
# File 'lib/uri_template/rfc6570/regex_builder.rb', line 71 def group(capture = false) self << '(' self << '?:' unless capture yield self << ')' end |
- (Object) join
51 52 53 |
# File 'lib/uri_template/rfc6570/regex_builder.rb', line 51 def join return @source.join end |
- (Object) length(*args)
55 56 57 |
# File 'lib/uri_template/rfc6570/regex_builder.rb', line 55 def length(*args) self << format_length(*args) end |
- (Object) lookahead
84 85 86 87 88 |
# File 'lib/uri_template/rfc6570/regex_builder.rb', line 84 def lookahead self << '(?=' yield self << ')' end |
- (Object) negative_lookahead
78 79 80 81 82 |
# File 'lib/uri_template/rfc6570/regex_builder.rb', line 78 def negative_lookahead self << '(?!' yield self << ')' end |
- (Object) push(*args)
34 35 36 37 |
# File 'lib/uri_template/rfc6570/regex_builder.rb', line 34 def push(*args) @source.push(*args) self end |
- (Object) reluctant
67 68 69 |
# File 'lib/uri_template/rfc6570/regex_builder.rb', line 67 def reluctant self << '?' end |
- (Object) separated_list(first = true, length = 0, min = 1, &block)
94 95 96 97 98 99 100 101 102 |
# File 'lib/uri_template/rfc6570/regex_builder.rb', line 94 def separated_list(first = true, length = 0, min = 1, &block) if first yield min -= 1 end self.push('(?:').escaped_separator yield self.push(')').length(length, min) end |