Class: Processing::BasicSketch

Inherits:
Creator
  • Object
show all
Defined in:
lib/jruby_art/creators/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.



174
175
176
# File 'lib/jruby_art/creators/creator.rb', line 174

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

#basic_template_modeObject



178
179
180
# File 'lib/jruby_art/creators/creator.rb', line 178

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

#create!(path, args) ⇒ Object



182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/jruby_art/creators/creator.rb', line 182

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)
  @title = StringExtra.new(main_file).titleize
  @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