Class: Doze::URITemplate::Composite

Inherits:
Doze::URITemplate show all
Defined in:
lib/doze/uri_template.rb

Direct Known Subclasses

WithPrefix

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Doze::URITemplate

#+, #anchored_regexp, compile, #compile_expand!, #inspect, #match, #match_with_trailing, #start_anchored_regexp, #with_prefix

Constructor Details

#initialize(parts) ⇒ Composite

Returns a new instance of Composite.



170
171
172
# File 'lib/doze/uri_template.rb', line 170

def initialize(parts)
  @parts = parts
end

Instance Attribute Details

#partsObject (readonly)

Returns the value of attribute parts.



198
199
200
# File 'lib/doze/uri_template.rb', line 198

def parts
  @parts
end

Instance Method Details

#expand(vars) ⇒ Object



182
183
184
# File 'lib/doze/uri_template.rb', line 182

def expand(vars)
  @parts.map {|p| p.expand(vars)}.join
end

#expand_code_fragmentObject



194
195
196
# File 'lib/doze/uri_template.rb', line 194

def expand_code_fragment
  @parts.map {|p| p.expand_code_fragment}.join
end

#partially_expand(vars) ⇒ Object



186
187
188
# File 'lib/doze/uri_template.rb', line 186

def partially_expand(vars)
  Composite.new(@parts.map {|p| p.partially_expand(vars)})
end

#regexp_fragmentObject



174
175
176
# File 'lib/doze/uri_template.rb', line 174

def regexp_fragment
  @parts.map {|p| p.regexp_fragment}.join
end

#to_sObject



178
179
180
# File 'lib/doze/uri_template.rb', line 178

def to_s
  @parts.join
end

#variablesObject



190
191
192
# File 'lib/doze/uri_template.rb', line 190

def variables
  @variables ||= @parts.map {|p| p.variables}.flatten
end