Class: Generator::TemplateDir

Inherits:
Object
  • Object
show all
Defined in:
lib/ngi/generator.rb

Overview

An extraction of the template file/directory for the generator… This way it can be separated, redefined, and tested.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(component) ⇒ TemplateDir

Returns a new instance of TemplateDir.



58
59
60
61
62
# File 'lib/ngi/generator.rb', line 58

def initialize(component)
  @dir = "#{Utils::CurrentDir.dir}/templates/"
  @dir << "#{component['type']}/#{component['language']}"
  @dir << "/#{component['using']}/#{component['template']}"
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir.



56
57
58
# File 'lib/ngi/generator.rb', line 56

def dir
  @dir
end

Instance Method Details

#readObject



64
65
66
67
68
69
70
# File 'lib/ngi/generator.rb', line 64

def read
  f = File.open(@dir)
  content = f.read
  f.close

  content
end