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