Class: Ace::Demo::Organisms::TapeCreator
- Inherits:
-
Object
- Object
- Ace::Demo::Organisms::TapeCreator
- Defined in:
- lib/ace/demo/organisms/tape_creator.rb
Instance Method Summary collapse
- #create(name:, commands:, description: nil, tags: nil, font_size: 16, width: 960, height: 480, timeout: "2s", format: "gif", force: false, dry_run: false) ⇒ Object
-
#initialize(writer: Molecules::TapeWriter.new) ⇒ TapeCreator
constructor
A new instance of TapeCreator.
Constructor Details
#initialize(writer: Molecules::TapeWriter.new) ⇒ TapeCreator
Returns a new instance of TapeCreator.
9 10 11 |
# File 'lib/ace/demo/organisms/tape_creator.rb', line 9 def initialize(writer: Molecules::TapeWriter.new) @writer = writer end |
Instance Method Details
#create(name:, commands:, description: nil, tags: nil, font_size: 16, width: 960, height: 480, timeout: "2s", format: "gif", force: false, dry_run: false) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ace/demo/organisms/tape_creator.rb', line 13 def create(name:, commands:, description: nil, tags: nil, font_size: 16, width: 960, height: 480, timeout: "2s", format: "gif", force: false, dry_run: false) safe_name = Atoms::DemoNameSanitizer.sanitize(name) scene_commands = Array(commands).reject { |command| command.to_s.strip.empty? } scene_commands = ["echo 'Hello from #{safe_name}'"] if scene_commands.empty? content = build_yaml_template( name: safe_name, commands: scene_commands, description: description, tags: , font_size: font_size, width: width, height: height, timeout: timeout, format: format ) path = nil unless dry_run path = @writer.write(name: safe_name, content: content, force: force, extension: ".tape.yml") end {content: content, path: path, dry_run: dry_run} end |