Class: Victor::CLI::RubySource
- Inherits:
-
Object
- Object
- Victor::CLI::RubySource
- Includes:
- DSL
- Defined in:
- lib/victor/cli/ruby_source.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Instance Method Summary collapse
- #evaluate ⇒ Object
-
#initialize(code, filename = nil) ⇒ RubySource
constructor
A new instance of RubySource.
- #template(template) ⇒ Object
Constructor Details
#initialize(code, filename = nil) ⇒ RubySource
Returns a new instance of RubySource.
7 8 9 10 |
# File 'lib/victor/cli/ruby_source.rb', line 7 def initialize(code, filename = nil) @code = code @filename = filename end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
5 6 7 |
# File 'lib/victor/cli/ruby_source.rb', line 5 def code @code end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
5 6 7 |
# File 'lib/victor/cli/ruby_source.rb', line 5 def filename @filename end |
Instance Method Details
#evaluate ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/victor/cli/ruby_source.rb', line 12 def evaluate if filename instance_eval code, filename else instance_eval code end end |
#template(template) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/victor/cli/ruby_source.rb', line 20 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 |