Class: SketchWriter
- Inherits:
-
Object
- Object
- SketchWriter
- 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
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#sketch ⇒ Object
readonly
Returns the value of attribute sketch.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(path) ⇒ SketchWriter
constructor
A new instance of SketchWriter.
- #write ⇒ Object
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
#file ⇒ Object (readonly)
Returns the value of attribute file.
48 49 50 |
# File 'lib/picrate/creators/sketch_writer.rb', line 48 def file @file end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
48 49 50 |
# File 'lib/picrate/creators/sketch_writer.rb', line 48 def height @height end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
48 49 50 |
# File 'lib/picrate/creators/sketch_writer.rb', line 48 def mode @mode end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
48 49 50 |
# File 'lib/picrate/creators/sketch_writer.rb', line 48 def name @name end |
#sketch ⇒ Object (readonly)
Returns the value of attribute sketch.
48 49 50 |
# File 'lib/picrate/creators/sketch_writer.rb', line 48 def sketch @sketch end |
#width ⇒ Object (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
#write ⇒ Object
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 |