Class: Processing::EmacsSketch

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

Creator::ALL_DIGITS

Instance Method Summary collapse

Methods inherited from Creator

#already_exist, #usage

Instance Method Details

#create!(path, args) ⇒ Object

Create a class wrapped sketch, given a path.



244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'lib/jruby_art/creators/creator.rb', line 244

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 = StringExtra.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? ? emacs_template : emacs_template_mode
  writer.save(template)
end

#emacs_templateObject



236
237
238
# File 'lib/jruby_art/creators/creator.rb', line 236

def emacs_template
  format(EMACS_BASIC, @name, @title, @width, @height, @name)
end

#emacs_template_modeObject



240
241
242
# File 'lib/jruby_art/creators/creator.rb', line 240

def emacs_template_mode
  format(EMACS_MODE, @name, @title, @width, @height, @mode, @name)
end