Class: TVdb::Template
- Inherits:
-
Object
- Object
- TVdb::Template
- Defined in:
- lib/tvdb/urls.rb
Instance Attribute Summary collapse
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #%(values) ⇒ Object
-
#initialize(template) ⇒ Template
constructor
A new instance of Template.
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
#template ⇒ Object (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 |