Class: TVdb::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/tvdb/urls.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template) ⇒ Template

Returns a new instance of Template.



28
29
30
# File 'lib/tvdb/urls.rb', line 28

def initialize(template)
  @template = template
end

Instance Attribute Details

#templateObject (readonly)

Returns the value of attribute template.



26
27
28
# File 'lib/tvdb/urls.rb', line 26

def template
  @template
end

Instance Method Details

#%(values) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/tvdb/urls.rb', line 32

def %(values)
  @template.gsub(/\{\{(.*?)\}\}/ ){
    value = values[$1] || values[$1.to_sym]
    raise "Value for #{$1} not found" if value.nil?
    value.to_s
  }
end