Class: Idcf::Cli::Lib::Util::Template
- Inherits:
-
Object
- Object
- Idcf::Cli::Lib::Util::Template
- Defined in:
- lib/idcf/cli/lib/util/template.rb
Overview
template
Instance Method Summary collapse
-
#fetch(path, attr = {}) ⇒ Object
return string.
- #set(name, value) ⇒ Object
Instance Method Details
#fetch(path, attr = {}) ⇒ Object
return string
17 18 19 20 21 22 23 24 |
# File 'lib/idcf/cli/lib/util/template.rb', line 17 def fetch(path, attr = {}) tmp_path = "#{Idcf::Cli::Conf::Const::TEMPLATE_DIR}/#{path}" attr.each do |k, v| set(k, v) end f_content = File.open(File.(tmp_path)).read ERB.new(f_content).result(binding) end |
#set(name, value) ⇒ Object
9 10 11 |
# File 'lib/idcf/cli/lib/util/template.rb', line 9 def set(name, value) instance_variable_set("@#{name}", value) end |