class Addressable::Template
def extract_suffix_operator(
-
(String)
- The extracted result.
Parameters:
-
mapping
(Hash
) -- The mapping of variables to values. -
variables
(Array
) -- The variables the operator is working on. -
argument
(String
) -- The argument to the operator. -
processor
(#restore
) -- The processor object. -
value
(String
) -- The unparsed value to extract from.
def extract_suffix_operator( value, processor, argument, variables, mapping) if variables.size != 1 raise InvalidTemplateOperatorError, "Template operator 'suffix' takes exactly one variable." end if value[-argument.size..-1] != argument raise TemplateOperatorAbortedError, "Value for template operator 'suffix' missing expected suffix." end values = value.split(argument, -1) values.pop if values[-1] == "" if processor && processor.respond_to?(:restore) values.map! { |value| processor.restore(variables.first, value) } end values = values.first if values.size == 1 if mapping[variables.first] == nil || mapping[variables.first] == values mapping[variables.first] = values else raise TemplateOperatorAbortedError, "Value mismatch for repeated variable." end end