Class: Creator::BasicSketch

Inherits:
Base
  • 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 Base

Creator::Base::ALL_DIGITS

Instance Method Summary collapse

Methods inherited from Base

#already_exist, #usage

Instance Method Details

#basic_templateObject

Create a blank sketch, given a path.



185
186
187
# File 'lib/jruby_art/creators/creator.rb', line 185

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

#basic_template_modeObject



189
190
191
# File 'lib/jruby_art/creators/creator.rb', line 189

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

#create!(path, args) ⇒ Object



193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/jruby_art/creators/creator.rb', line 193

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]
  return writer.save(basic_template) if args[2].nil?
  @mode = args[2].upcase
  writer.save(basic_template_mode)
end