Class: SketchWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/picrate/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) ⇒ SketchWriter

Returns a new instance of SketchWriter.



49
50
51
52
53
54
55
56
57
58
# File 'lib/picrate/creators/sketch_writer.rb', line 49

def initialize(path)
  param = Parameters.read
  @sketch = SketchClass.new(path)
  @class = sketch.class_name
  sketch_param = param.fetch('sketch')
  @width = sketch_param.fetch('width')
  @height = sketch_param.fetch('height')
  @mode = sketch_param.fetch('mode')
  binding
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



48
49
50
# File 'lib/picrate/creators/sketch_writer.rb', line 48

def file
  @file
end

#heightObject (readonly)

Returns the value of attribute height.



48
49
50
# File 'lib/picrate/creators/sketch_writer.rb', line 48

def height
  @height
end

#modeObject (readonly)

Returns the value of attribute mode.



48
49
50
# File 'lib/picrate/creators/sketch_writer.rb', line 48

def mode
  @mode
end

#nameObject (readonly)

Returns the value of attribute name.



48
49
50
# File 'lib/picrate/creators/sketch_writer.rb', line 48

def name
  @name
end

#sketchObject (readonly)

Returns the value of attribute sketch.



48
49
50
# File 'lib/picrate/creators/sketch_writer.rb', line 48

def sketch
  @sketch
end

#widthObject (readonly)

Returns the value of attribute width.



48
49
50
# File 'lib/picrate/creators/sketch_writer.rb', line 48

def width
  @width
end

Instance Method Details

#writeObject



60
61
62
# File 'lib/picrate/creators/sketch_writer.rb', line 60

def write
  File.open(sketch.filename, 'w+') { |f| f.write TEMPLATE.result(binding) }
end