Class: Rub2::JobScript
- Inherits:
-
Object
- Object
- Rub2::JobScript
- Defined in:
- lib/rub2.rb
Instance Attribute Summary collapse
-
#array_request ⇒ Object
Returns the value of attribute array_request.
-
#commands ⇒ Object
Returns the value of attribute commands.
-
#inherit_environment ⇒ Object
Returns the value of attribute inherit_environment.
-
#log ⇒ Object
Returns the value of attribute log.
-
#log_path ⇒ Object
Returns the value of attribute log_path.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#queue ⇒ Object
Returns the value of attribute queue.
-
#resource ⇒ Object
Returns the value of attribute resource.
-
#shell ⇒ Object
Returns the value of attribute shell.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(name) ⇒ JobScript
constructor
A new instance of JobScript.
-
#make_array_request_string ⇒ Object
Range (1..100) or Array [1,10,50] -> ‘-t 1-100’ or -t ‘1,10,50’.
Constructor Details
#initialize(name) ⇒ JobScript
Returns a new instance of JobScript.
28 29 30 31 32 33 |
# File 'lib/rub2.rb', line 28 def initialize(name) @name = name @shell = '/bin/bash' @log_path = make_default_log_path(name) @uri = nil end |
Instance Attribute Details
#array_request ⇒ Object
Returns the value of attribute array_request.
17 18 19 |
# File 'lib/rub2.rb', line 17 def array_request @array_request end |
#commands ⇒ Object
Returns the value of attribute commands.
17 18 19 |
# File 'lib/rub2.rb', line 17 def commands @commands end |
#inherit_environment ⇒ Object
Returns the value of attribute inherit_environment.
17 18 19 |
# File 'lib/rub2.rb', line 17 def inherit_environment @inherit_environment end |
#log ⇒ Object
Returns the value of attribute log.
17 18 19 |
# File 'lib/rub2.rb', line 17 def log @log end |
#log_path ⇒ Object
Returns the value of attribute log_path.
17 18 19 |
# File 'lib/rub2.rb', line 17 def log_path @log_path end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
26 27 28 |
# File 'lib/rub2.rb', line 26 def name @name end |
#queue ⇒ Object
Returns the value of attribute queue.
17 18 19 |
# File 'lib/rub2.rb', line 17 def queue @queue end |
#resource ⇒ Object
Returns the value of attribute resource.
17 18 19 |
# File 'lib/rub2.rb', line 17 def resource @resource end |
#shell ⇒ Object
Returns the value of attribute shell.
17 18 19 |
# File 'lib/rub2.rb', line 17 def shell @shell end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
26 27 28 |
# File 'lib/rub2.rb', line 26 def source @source end |
#uri ⇒ Object
Returns the value of attribute uri.
17 18 19 |
# File 'lib/rub2.rb', line 17 def uri @uri end |
Instance Method Details
#build ⇒ Object
35 36 37 |
# File 'lib/rub2.rb', line 35 def build @source = ERB.new(ScriptTemplate, nil, '-').result(binding) end |
#make_array_request_string ⇒ Object
Range (1..100) or Array [1,10,50] -> ‘-t 1-100’ or -t ‘1,10,50’
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rub2.rb', line 40 def make_array_request_string @array_request = (1..@commands.size) if @array_request.nil? limit = '' unless @slot_limit.nil? limit = "%#{@slot_limit}" end if @array_request.kind_of?(Range) last = nil if @array_request.exclude_end? last = @array_request.last - 1 else last = @array_request.last end return sprintf("%d-%d%s", @array_request.first, last, limit) end return @array_request.sort.join(',') + limit end |