Class: Utils::ProcessJob
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
- #ok ⇒ Object
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(args:, probe_server: nil) ⇒ ProcessJob
constructor
A new instance of ProcessJob.
- #inspect ⇒ Object (also: #to_s)
- #ok_colorize(string) ⇒ Object
- #to_json ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(args:, probe_server: nil) ⇒ ProcessJob
Returns a new instance of ProcessJob.
10 11 12 13 |
# File 'lib/utils/probe_server.rb', line 10 def initialize(args:, probe_server: nil) @id = probe_server&.next_job_id @args = Array(args) end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
17 18 19 |
# File 'lib/utils/probe_server.rb', line 17 def args @args end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
15 16 17 |
# File 'lib/utils/probe_server.rb', line 15 def id @id end |
#ok ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/utils/probe_server.rb', line 25 def ok case @ok when false then 'n' when true then 'y' else '…' end end |
Instance Method Details
#as_json ⇒ Object
47 48 49 |
# File 'lib/utils/probe_server.rb', line 47 def as_json(*) { type:, id:, args:, } end |
#inspect ⇒ Object Also known as: to_s
41 42 43 |
# File 'lib/utils/probe_server.rb', line 41 def inspect ok_colorize("#{id} #{args.map { |a| a.include?(' ') ? a.inspect : a } * ' '}") end |
#ok_colorize(string) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/utils/probe_server.rb', line 33 def ok_colorize(string) case @ok when false then string.white.on_red when true then string.black.on_green else string end end |
#to_json ⇒ Object
51 52 53 |
# File 'lib/utils/probe_server.rb', line 51 def to_json(*) as_json.to_json(*) end |
#type ⇒ Object
21 22 23 |
# File 'lib/utils/probe_server.rb', line 21 def type 'process_job' end |