Class: Utils::ProbeServer::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/utils/probe_server.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(probe_server, args) ⇒ Job

Returns a new instance of Job.



20
21
22
23
# File 'lib/utils/probe_server.rb', line 20

def initialize(probe_server, args)
  @id           = probe_server.next_job_id
  @args         = args
end

Class Attribute Details

.colorize=(value) ⇒ Object (writeonly)

Sets the attribute colorize

Parameters:

  • value

    the value to set the attribute colorize to.



12
13
14
# File 'lib/utils/probe_server.rb', line 12

def colorize=(value)
  @colorize = value
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



27
28
29
# File 'lib/utils/probe_server.rb', line 27

def args
  @args
end

#idObject (readonly)

Returns the value of attribute id.



25
26
27
# File 'lib/utils/probe_server.rb', line 25

def id
  @id
end

#okObject



31
32
33
34
35
36
37
# File 'lib/utils/probe_server.rb', line 31

def ok
  case @ok
  when false then 'n'
  when true  then 'y'
  else            ''
  end
end

Class Method Details

.colorize?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/utils/probe_server.rb', line 14

def colorize?
  !!@colorize
end

Instance Method Details

#inspectObject Also known as: to_s



48
49
50
51
52
# File 'lib/utils/probe_server.rb', line 48

def inspect
  ok_colorize(
    "#<Job id=#{id} args=#{args.inspect} ok=#{ok}>"
  )
end

#ok_colorize(string) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/utils/probe_server.rb', line 39

def ok_colorize(string)
  return string unless self.class.colorize?
  case @ok
  when false then string.white.on_red
  when true  then string.black.on_green
  else            string.black.on_yellow
  end
end