Class: SketchWriter

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#fileObject (readonly)

Returns the value of attribute file.



28
29
30
# File 'lib/jruby_art/creators/sketch_writer.rb', line 28

def file
  @file
end

#paramObject (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

#writeObject



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