Class: SketchParameters
- Inherits:
-
Object
- Object
- SketchParameters
- Defined in:
- lib/jruby_art/creators/sketch_writer.rb
Overview
The SketchParameters class knows how to format, size, title & class name
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #class_name ⇒ Object
-
#initialize(name:, args:) ⇒ SketchParameters
constructor
A new instance of SketchParameters.
- #sketch_size ⇒ Object
- #sketch_title ⇒ Object
Constructor Details
#initialize(name:, args:) ⇒ SketchParameters
Returns a new instance of SketchParameters.
5 6 7 8 |
# File 'lib/jruby_art/creators/sketch_writer.rb', line 5 def initialize(name:, args:) @name = name @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
4 5 6 |
# File 'lib/jruby_art/creators/sketch_writer.rb', line 4 def args @args end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/jruby_art/creators/sketch_writer.rb', line 4 def name @name end |
Instance Method Details
#class_name ⇒ Object
10 11 12 |
# File 'lib/jruby_art/creators/sketch_writer.rb', line 10 def class_name name.split('_').collect(&:capitalize).join end |
#sketch_size ⇒ Object
19 20 21 22 23 |
# File 'lib/jruby_art/creators/sketch_writer.rb', line 19 def sketch_size mode = args.length == 3 ? format(', %s', args[2].upcase) : '' return 'size 200, 200' if args.empty? format('size %d, %d%s', args[0].to_i, args[1].to_i, mode) end |
#sketch_title ⇒ Object
14 15 16 17 |
# File 'lib/jruby_art/creators/sketch_writer.rb', line 14 def sketch_title human = name.split('_').collect(&:capitalize).join(' ') format("sketch_title '%s'", human) end |