class Sketch
Implements methods and class_methods
omits blank line after draw uses private method_lines
to format method lines
Attributes
param[R]
Public Class Methods
new(param)
click to toggle source
# File lib/jruby_art/creators/sketch_writer.rb, line 55 def initialize(param) @param = param end
Public Instance Methods
class_methods()
click to toggle source
# File lib/jruby_art/creators/sketch_writer.rb, line 69 def class_methods lines = [format('class %<name>s < Processing::App', name: param.class_name)] lines.concat methods(INDENT) lines << 'end' end
methods(indent)
click to toggle source
# File lib/jruby_art/creators/sketch_writer.rb, line 62 def methods(indent) lines = [] lines.concat method_lines('settings', param.sketch_size, indent) lines.concat method_lines('setup', param.sketch_title, indent) lines.concat method_lines('draw', BLANK, indent) end
Private Instance Methods
content(content, indent)
click to toggle source
# File lib/jruby_art/creators/sketch_writer.rb, line 77 def content(content, indent) return BLANK if content.empty? format(' %<indent>s%<content>s', indent: indent, content: content) end
method_lines(name, content, indent)
click to toggle source
# File lib/jruby_art/creators/sketch_writer.rb, line 83 def method_lines(name, content, indent) one = format('%<indent>sdef %<name>s', indent: indent, name: name) two = content(content, indent) three = format('%<indent>send', indent: indent) return [one, two, three] if /draw/.match?(name) [one, two, three, BLANK] end