Class: Processing::ClassSketch

Inherits:
Creator
  • Object
show all
Defined in:
lib/jruby_art/creators/creator.rb

Overview

This class creates class wrapped sketches, with an optional render mode

Constant Summary

Constants inherited from Creator

Processing::Creator::ALL_DIGITS

Instance Method Summary collapse

Methods inherited from Creator

#already_exist, #usage

Instance Method Details

#class_templateObject



199
200
201
# File 'lib/jruby_art/creators/creator.rb', line 199

def class_template
  format(CLASS_BASIC, @name, @title, @width, @height)
end

#class_template_modeObject



203
204
205
# File 'lib/jruby_art/creators/creator.rb', line 203

def class_template_mode
  format(CLASS_MODE, @name, @title, @width, @height, @mode)
end

#create!(path, args) ⇒ Object

Create a class wrapped sketch, given a path.



207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/jruby_art/creators/creator.rb', line 207

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