Class: Processing::BasicSketch

Inherits:
Creator
  • Object
show all
Defined in:
lib/ruby-processing/exporters/creator.rb

Overview

This class creates bare sketches, with an optional render mode

Constant Summary

Constants inherited from Creator

Creator::ALL_DIGITS

Instance Method Summary collapse

Methods inherited from Creator

#already_exist, #usage

Instance Method Details

#basic_templateObject

Create a blank sketch, given a path.



101
102
103
# File 'lib/ruby-processing/exporters/creator.rb', line 101

def basic_template
  format(BASIC, @width, @height)
end

#basic_template_modeObject



105
106
107
# File 'lib/ruby-processing/exporters/creator.rb', line 105

def basic_template_mode
  format(BASIC_MODE, @width, @height, @mode)
end

#create!(path, args) ⇒ Object



109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/ruby-processing/exporters/creator.rb', line 109

def create!(path, args)
  return usage if /\?/ =~ path || /--help/ =~ path
  # Check to make sure that the main file doesn't exist already
  already_exist(path)
  main_file = File.basename(path, '.rb') # allow uneeded extension input
  writer = SketchWriter.new(main_file)
  @width = args[0]
  @height = args[1]
  @mode = args[2].upcase unless args[2].nil?
  template = @mode.nil? ? basic_template : basic_template_mode
  writer.save(template)
end