Class: KDL::Types::URLTemplate::StringExpansion

Inherits:
Part
  • Object
show all
Defined in:
lib/kdl/types/url_template.rb

Instance Method Summary collapse

Methods inherited from Part

allow_reserved?, #expand_variables, keep_empties?, #prefix, #separator, with_name?

Constructor Details

#initialize(variables) ⇒ StringExpansion

Returns a new instance of StringExpansion.



241
242
243
244
# File 'lib/kdl/types/url_template.rb', line 241

def initialize(variables)
  super()
  @variables = variables
end

Instance Method Details

#expand(values) ⇒ Object



246
247
248
249
250
251
# File 'lib/kdl/types/url_template.rb', line 246

def expand(values)
  expanded = expand_variables(values)
  return '' if expanded.empty?

  prefix + expanded.join(separator)
end