Class: Pytty::Client::ProcessYield

Inherits:
Object
  • Object
show all
Defined in:
lib/pytty/client/process_yield.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#idObject (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

#attachObject



30
31
32
# File 'lib/pytty/client/process_yield.rb', line 30

def attach
  Pytty::Client::Api::Attach.run id: @id
end

#spawn(tty:, interactive:) ⇒ Object



26
27
28
# File 'lib/pytty/client/process_yield.rb', line 26

def spawn(tty:, interactive:)
  Pytty::Client::Api::Spawn.run id: @id, tty: tty, interactive: interactive
end

#to_sObject



22
23
24
# File 'lib/pytty/client/process_yield.rb', line 22

def to_s
  "#{@id} #{@cmd}"
end