Class: Victor::CLI::Commands::GenerateSVG

Inherits:
Base
  • Object
show all
Defined in:
lib/victor/cli/commands/generate_svg.rb

Instance Method Summary collapse

Instance Method Details

#runObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/victor/cli/commands/generate_svg.rb', line 19

def run
  ruby_file = args["RUBY_FILE"]
  svg_file = args["SVG_FILE"]
  template = args['--template']
  code = File.read ruby_file

  ruby_code = RubyCode.new code
  ruby_code.evaluate
  ruby_code.template template if template
  
  if svg_file
    ruby_code.svg.save svg_file
    say "Saved #{svg_file}"
  else
    puts ruby_code.svg.render
  end
end