Class: Pytty::Client::ProcessYield
- Inherits:
-
Object
- Object
- Pytty::Client::ProcessYield
- Defined in:
- lib/pytty/client/process_yield.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
- #attach(interactive:) ⇒ Object
-
#initialize(id:, cmd:, env:, pid:, status:) ⇒ ProcessYield
constructor
A new instance of ProcessYield.
- #rm ⇒ Object
- #running? ⇒ Boolean
- #spawn(tty:, interactive:) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(id:, cmd:, env:, pid:, status:) ⇒ ProcessYield
Returns a new instance of ProcessYield.
4 5 6 7 8 9 10 |
# File 'lib/pytty/client/process_yield.rb', line 4 def initialize(id:, cmd:, env:, pid:, status:) @cmd = cmd @env = env @pid = pid @id = id @status = status end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/pytty/client/process_yield.rb', line 12 def id @id end |
Class Method Details
.from_json(json) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/pytty/client/process_yield.rb', line 14 def self.from_json(json) self.new({ id: json.fetch("id"), cmd: json.fetch("cmd"), env: json.fetch("env"), pid: json.fetch("pid"), status: json.fetch("status") }) end |
Instance Method Details
#attach(interactive:) ⇒ Object
45 46 47 |
# File 'lib/pytty/client/process_yield.rb', line 45 def attach(interactive:) Pytty::Client::Api::Attach.run id: @id, interactive: interactive end |
#rm ⇒ Object
37 38 39 |
# File 'lib/pytty/client/process_yield.rb', line 37 def rm Pytty::Client::Api::Rm.run id: @id end |
#running? ⇒ Boolean
24 25 26 |
# File 'lib/pytty/client/process_yield.rb', line 24 def running? !@pid.nil? end |
#spawn(tty:, interactive:) ⇒ Object
41 42 43 |
# File 'lib/pytty/client/process_yield.rb', line 41 def spawn(tty:, interactive:) Pytty::Client::Api::Spawn.run id: @id, tty: tty, interactive: interactive end |
#to_s ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/pytty/client/process_yield.rb', line 28 def to_s fields = [] fields << @id fields << running? fields << @status fields << @cmd.join(" ") fields.join("\t") end |