Class: Tony::Generator
- Inherits:
-
Object
- Object
- Tony::Generator
- Defined in:
- lib/tony/generator.rb
Instance Attribute Summary collapse
-
#combination ⇒ Object
Returns the value of attribute combination.
-
#description ⇒ Object
Returns the value of attribute description.
-
#files ⇒ Object
Returns the value of attribute files.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize {|_self| ... } ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize {|_self| ... } ⇒ Generator
Returns a new instance of Generator.
7 8 9 |
# File 'lib/tony/generator.rb', line 7 def initialize(&block) yield self end |
Instance Attribute Details
#combination ⇒ Object
Returns the value of attribute combination.
5 6 7 |
# File 'lib/tony/generator.rb', line 5 def combination @combination end |
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/tony/generator.rb', line 5 def description @description end |
#files ⇒ Object
Returns the value of attribute files.
5 6 7 |
# File 'lib/tony/generator.rb', line 5 def files @files end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/tony/generator.rb', line 5 def name @name end |
Instance Method Details
#generate ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/tony/generator.rb', line 11 def generate files.each do |path, contents| FileUtils.mkdir_p(File.dirname(path)) puts "create #{path}" unless File.exist?(path) puts "append #{path}" if File.exist?(path) File.open(path, 'a') do |file| file.puts(contents) end end end |