Class: URITemplate::RFC6570::Expression::Unnamed
- Inherits:
-
URITemplate::RFC6570::Expression
- Object
- Token
- URITemplate::RFC6570::Expression
- URITemplate::RFC6570::Expression::Unnamed
- Defined in:
- lib/uri_template/rfc6570/expression/unnamed.rb
Constant Summary
Constants inherited from URITemplate::RFC6570::Expression
BASE_LEVEL, CHARACTER_CLASS, LIST_CONNECTOR, OPERATOR, PAIR_CONNECTOR, PAIR_IF_EMPTY, PREFIX, SEPARATOR
Constants included from Token
Instance Attribute Summary
Attributes inherited from URITemplate::RFC6570::Expression
Attributes included from Expression
Instance Method Summary collapse
Methods inherited from URITemplate::RFC6570::Expression
#arity, #expand, #expand_partial, #extract, #initialize, #level, #to_s
Methods included from ClassMethods
#generate_hash_extractor, #hash_extractor, #hash_extractors, #regex_builder
Methods included from Expression
Methods included from Token
#ends_with_slash?, #expand, #expand_partial, #host?, #scheme?, #size, #starts_with_slash?, #to_s, #variables
Constructor Details
This class inherits a constructor from URITemplate::RFC6570::Expression
Instance Method Details
#self_pair(_, value, max_length = 0, &block) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/uri_template/rfc6570/expression/unnamed.rb', line 28 def self_pair(_, value, max_length = 0,&block) if block ev = value.map(&block).join(self.class::LIST_CONNECTOR) else ev = escape(value) end cut( ev, max_length ,&block) end |
#to_r_source ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/uri_template/rfc6570/expression/unnamed.rb', line 37 def to_r_source vs = @variable_specs.size - 1 i = 0 source = regex_builder source.group do source.escaped_prefix @variable_specs.each do | var, , max_length | last = (vs == i) first = (i == 0) if source.group(true) do source.separated_list(first) do source.group do source.character_class('+').reluctant source.escaped_pair_connector end.length('?') source.character_class(max_length) end end else source.escaped_separator unless first source.group(true) do if last source.character_class_with_comma(max_length) else source.character_class(max_length) end end end i = i+1 end end.length('?') return source.join end |