Class: Phantom::Process

Inherits:
Object
  • Object
show all
Defined in:
lib/phantom/process.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pid = nil, memory_usage = nil, command = nil, port = nil) ⇒ Process

Returns a new instance of Process.



30
31
32
33
34
35
# File 'lib/phantom/process.rb', line 30

def initialize(pid = nil, memory_usage = nil, command = nil, port = nil)
  @pid = pid
  @memory_usage = memory_usage
  @command = command
  @port = port
end

Instance Attribute Details

#commandObject

Returns the value of attribute command.



7
8
9
# File 'lib/phantom/process.rb', line 7

def command
  @command
end

#memory_usageObject

Returns the value of attribute memory_usage.



7
8
9
# File 'lib/phantom/process.rb', line 7

def memory_usage
  @memory_usage
end

#pidObject

Returns the value of attribute pid.



7
8
9
# File 'lib/phantom/process.rb', line 7

def pid
  @pid
end

#portObject

Returns the value of attribute port.



7
8
9
# File 'lib/phantom/process.rb', line 7

def port
  @port
end

Class Method Details

.from_string(str) ⇒ Object



11
12
13
14
# File 'lib/phantom/process.rb', line 11

def from_string(str)
  args = parse_string(str)
  new(*args)
end

Instance Method Details

#inspectObject



51
52
53
# File 'lib/phantom/process.rb', line 51

def inspect
  "pid: #{pid}, port: #{port}, memory_usage: #{memory_usage}, command: #{command}"
end

#killObject



37
38
39
40
# File 'lib/phantom/process.rb', line 37

def kill
  $logger.info "killing #{self}"
  Utils::Shell.execute "kill #{pid}"
end

#startObject



42
43
44
45
# File 'lib/phantom/process.rb', line 42

def start
  $logger.info "starting phantomjs on port #{port}"
  Utils::Shell.execute start_command
end

#to_sObject



47
48
49
# File 'lib/phantom/process.rb', line 47

def to_s
  inspect
end