Class: Processing::Creator

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

Overview

An abstract class providing common methods for real creators

Direct Known Subclasses

BasicSketch, ClassSketch, EmacsSketch, Inner

Constant Summary collapse

ALL_DIGITS =
/\A\d+\Z/

Instance Method Summary collapse

Instance Method Details

#already_exist(path) ⇒ Object



159
160
161
162
163
164
165
# File 'lib/jruby_art/creators/creator.rb', line 159

def already_exist(path)
  underscore = StringExtra.new(path).underscore
  new_file = "#{File.dirname(path)}/#{underscore}.rb"
  return if !FileTest.exist?(path) && !FileTest.exist?(new_file)
  puts 'That file already exists!'
  exit
end

#usageObject

Show the help/usage message for create.



168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/jruby_art/creators/creator.rb', line 168

def usage
  puts "\n  Usage: k9 create <sketch_to_generate> <width> <height> <mode>\n  mode can be P2D / P3D.\n  Use    --wrap for a sketch wrapped as a class\n  Use    --inner to generated a ruby version of 'java' Inner class\n  Examples: k9 create app 800 600\n  k9 create app 800 600 p3d --wrap\n  k9 create inner_class --inner\n\n  USAGE\nend\n"