Class: Processing::SketchWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/jruby_art/creators/creator.rb

Overview

Write file to disk

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ SketchWriter

Returns a new instance of SketchWriter.



131
132
133
134
# File 'lib/jruby_art/creators/creator.rb', line 131

def initialize(path)
  underscore = StringExtra.new(path).underscore
  @file = "#{File.dirname(path)}/#{underscore}.rb"
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



130
131
132
# File 'lib/jruby_art/creators/creator.rb', line 130

def file
  @file
end

Instance Method Details

#save(template) ⇒ Object



136
137
138
139
140
# File 'lib/jruby_art/creators/creator.rb', line 136

def save(template)
  File.open(file, 'w+') do |f|
    f.write(template)
  end
end