Class: Zeno::Makefile
- Inherits:
-
FileGenerator
- Object
- FileGenerator
- Zeno::Makefile
- Defined in:
- lib/zeno/makefile.rb
Instance Attribute Summary
Attributes inherited from FileGenerator
Instance Method Summary collapse
- #add_target(target, rules) ⇒ Object
- #generate ⇒ Object
-
#initialize(path) ⇒ Makefile
constructor
A new instance of Makefile.
- #to_s ⇒ Object
Methods inherited from FileGenerator
Constructor Details
#initialize(path) ⇒ Makefile
Returns a new instance of Makefile.
23 24 25 26 |
# File 'lib/zeno/makefile.rb', line 23 def initialize(path) super @targets = Hash.new end |
Instance Method Details
#add_target(target, rules) ⇒ Object
28 29 30 |
# File 'lib/zeno/makefile.rb', line 28 def add_target(target, rules) @targets[target] = rules end |
#generate ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/zeno/makefile.rb', line 32 def generate File.open(@path, 'w') do |makefile| makefile.puts self.to_s end nil end |
#to_s ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/zeno/makefile.rb', line 40 def to_s output = super output += "\n" @targets.each do |key, value| output += "#{key}:\n" if value.is_a? Array value.each do |e| output += "\t#{e}\n" end else output += "\t#{value}\n" end output += "\n" end output end |