Class: Victor::CLI::RubyCode

Inherits:
Object
  • Object
show all
Includes:
DSL
Defined in:
lib/victor/cli/ruby_code.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code) ⇒ RubyCode

Returns a new instance of RubyCode.



7
8
9
# File 'lib/victor/cli/ruby_code.rb', line 7

def initialize(code)
  @code = code
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



5
6
7
# File 'lib/victor/cli/ruby_code.rb', line 5

def code
  @code
end

Instance Method Details

#evaluateObject



11
12
13
# File 'lib/victor/cli/ruby_code.rb', line 11

def evaluate
  instance_eval code
end

#template(template) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/victor/cli/ruby_code.rb', line 15

def template(template)
  if built_in_templates.include? template
    template = template.to_sym
  elsif !File.exist? template
    raise "Template not found #{template}\nAvailable templates: #{built_in_templates.join ', '}, or a file path"
  end

  svg.template = template
end