Class: SketchWriter
- Inherits:
-
Object
- Object
- SketchWriter
- Defined in:
- lib/jruby_art/creators/sketch_writer.rb
Overview
The file writer can write a sketch when given instance of Sketch type
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#param ⇒ Object
readonly
Returns the value of attribute param.
Instance Method Summary collapse
-
#initialize(path, args) ⇒ SketchWriter
constructor
A new instance of SketchWriter.
- #write ⇒ Object
Constructor Details
#initialize(path, args) ⇒ SketchWriter
Returns a new instance of SketchWriter.
30 31 32 33 |
# File 'lib/jruby_art/creators/sketch_writer.rb', line 30 def initialize(path, args) @param = SketchParameters.new(name: path, args: args) @file = format('%s/%s.rb', File.dirname(path), path) end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
28 29 30 |
# File 'lib/jruby_art/creators/sketch_writer.rb', line 28 def file @file end |
#param ⇒ Object (readonly)
Returns the value of attribute param.
28 29 30 |
# File 'lib/jruby_art/creators/sketch_writer.rb', line 28 def param @param end |
Instance Method Details
#write ⇒ Object
35 36 37 38 |
# File 'lib/jruby_art/creators/sketch_writer.rb', line 35 def write sketch = SketchFactory.create(param) File.open(file, 'w+') { |f| f.write sketch.join("\n") } end |