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.
6 7 8 9 |
# File 'lib/jruby_art/creators/sketch_writer.rb', line 6 def initialize(name:, args:) @name = name @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
5 6 7 |
# File 'lib/jruby_art/creators/sketch_writer.rb', line 5 def args @args end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/jruby_art/creators/sketch_writer.rb', line 5 def name @name end |
Instance Method Details
#class_name ⇒ Object
11 12 13 |
# File 'lib/jruby_art/creators/sketch_writer.rb', line 11 def class_name name.split('_').collect(&:capitalize).join end |
#sketch_size ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/jruby_art/creators/sketch_writer.rb', line 20 def sketch_size mode = args.length == 3 ? format(', %<mode>s', mode: args[2].upcase) : '' return 'size 200, 200' if args.empty? format( 'size %<width>d, %<height>d%<mode>s', width: args[0].to_i, height: args[1].to_i, mode: mode ) end |
#sketch_title ⇒ Object
15 16 17 18 |
# File 'lib/jruby_art/creators/sketch_writer.rb', line 15 def sketch_title human = name.split('_').collect(&:capitalize).join(' ') format("sketch_title '%<title>s'", title: human) end |