Class: Idcf::Cli::Lib::Util::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/idcf/cli/lib/util/template.rb

Overview

template

Instance Method Summary collapse

Instance Method Details

#fetch(path, attr = {}) ⇒ Object

return string

Parameters:

  • path (String)
  • attr (defaults to: {})


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.expand_path(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