Class: Splot::Command
- Inherits:
-
Object
show all
- Defined in:
- lib/splot/command.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(params = {}) ⇒ Command
Returns a new instance of Command.
5
6
7
8
9
10
|
# File 'lib/splot/command.rb', line 5
def initialize(params = {})
@file = params.fetch(:file).to_str
@include_path = params[:include_path]
@line_no = Integer(params[:line]) if params.has_key? :line
@preloader = params[:preloader].to_str if params.has_key? :preloader
end
|
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
3
4
5
|
# File 'lib/splot/command.rb', line 3
def file
@file
end
|
#include_path ⇒ Object
Returns the value of attribute include_path.
3
4
5
|
# File 'lib/splot/command.rb', line 3
def include_path
@include_path
end
|
#line_no ⇒ Object
Returns the value of attribute line_no.
3
4
5
|
# File 'lib/splot/command.rb', line 3
def line_no
@line_no
end
|
#preloader ⇒ Object
Returns the value of attribute preloader.
3
4
5
|
# File 'lib/splot/command.rb', line 3
def preloader
@preloader
end
|
Class Method Details
.for(file) ⇒ Object
12
13
14
15
16
17
|
# File 'lib/splot/command.rb', line 12
def self.for(file)
ObjectSpace.each_object(Class).select { |klass| klass < self }.each do |subklass|
return subklass if subklass.match? file
end
self
end
|
.match?(file) ⇒ Boolean
19
20
21
|
# File 'lib/splot/command.rb', line 19
def self.match?(file)
false
end
|
Instance Method Details
#command ⇒ Object
23
24
25
26
27
28
29
30
31
|
# File 'lib/splot/command.rb', line 23
def command
[
preloader, runner, include_args, file_arg, line_no_arg, ].compact * ' '
end
|
#file_arg ⇒ Object
33
34
35
|
# File 'lib/splot/command.rb', line 33
def file_arg
file
end
|
#include_args ⇒ Object
37
38
39
|
# File 'lib/splot/command.rb', line 37
def include_args
include_path ? "-I#{include_path}" : nil
end
|
#line_no_arg ⇒ Object
41
42
43
|
# File 'lib/splot/command.rb', line 41
def line_no_arg
line_no ? "-l #{line_no}" : nil
end
|
#runner ⇒ Object
45
46
47
|
# File 'lib/splot/command.rb', line 45
def runner
raise RunnerNotFoundError, "cannot determine runner for #{file.inspect}"
end
|