Module: URITemplate::RFC6570::Expression::ClassMethods

Included in:
URITemplate::RFC6570::Expression
Defined in:
lib/uri_template/rfc6570/expression.rb

Instance Method Summary collapse

Instance Method Details

#generate_hash_extractor(max_length) ⇒ Object



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/uri_template/rfc6570/expression.rb', line 169

def generate_hash_extractor(max_length)
  source = regex_builder
  source.push('\\A')
  source.escaped_separator
  source.capture do
    source.character_class('+').reluctant
  end
  source.group do
    source.escaped_pair_connector
    source.capture do
      source.character_class(max_length,0).reluctant
    end
  end.length('?')
  source.lookahead do
    source.push '\\z'
    source.push '|'
    source.escaped_separator
    source.push '[^'
      source.escaped_separator
    source.push ']'
  end
  return Regexp.new( source.join , Utils::KCODE_UTF8)
end

#hash_extractor(max_length) ⇒ Object



165
166
167
# File 'lib/uri_template/rfc6570/expression.rb', line 165

def hash_extractor(max_length)
  return hash_extractors[max_length]
end

#hash_extractorsObject



161
162
163
# File 'lib/uri_template/rfc6570/expression.rb', line 161

def hash_extractors
  @hash_extractors ||= Hash.new{|hsh, key| hsh[key] = generate_hash_extractor(key) }
end

#regex_builderObject



193
194
195
# File 'lib/uri_template/rfc6570/expression.rb', line 193

def regex_builder
  RegexBuilder.new(self)
end