Class: Bsdkrun::SandboxInfo
- Inherits:
-
Data
- Object
- Data
- Bsdkrun::SandboxInfo
- Defined in:
- lib/bsdkrun/types.rb
Overview
A machine as reported by bsdkrun ps --json.
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#cpus ⇒ Object
readonly
Returns the value of attribute cpus.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#detached ⇒ Object
readonly
Returns the value of attribute detached.
-
#exit_code ⇒ Object
readonly
Returns the value of attribute exit_code.
-
#finished_at ⇒ Object
readonly
Returns the value of attribute finished_at.
- #id ⇒ String readonly
-
#image ⇒ Object
readonly
Returns the value of attribute image.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#mem ⇒ Object
readonly
Returns the value of attribute mem.
-
#name ⇒ String?
readonly
DNS name on a network, or nil if unnamed.
-
#net_ip ⇒ Object
readonly
Returns the value of attribute net_ip.
-
#network ⇒ Object
readonly
Returns the value of attribute network.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#running ⇒ Object
readonly
Returns the value of attribute running.
-
#state_dir ⇒ Object
readonly
Returns the value of attribute state_dir.
-
#status ⇒ String
readonly
"running" or "exited" (derived from
running). -
#volume ⇒ Object
readonly
Returns the value of attribute volume.
Class Method Summary collapse
-
.from_row(row) ⇒ SandboxInfo
Map a
ps --jsonrow (String keys) to a typed instance. - .to_i_or_nil(value) ⇒ Object
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command
12 13 14 |
# File 'lib/bsdkrun/types.rb', line 12 def command @command end |
#cpus ⇒ Object (readonly)
Returns the value of attribute cpus
12 13 14 |
# File 'lib/bsdkrun/types.rb', line 12 def cpus @cpus end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at
12 13 14 |
# File 'lib/bsdkrun/types.rb', line 12 def created_at @created_at end |
#detached ⇒ Object (readonly)
Returns the value of attribute detached
12 13 14 |
# File 'lib/bsdkrun/types.rb', line 12 def detached @detached end |
#exit_code ⇒ Object (readonly)
Returns the value of attribute exit_code
12 13 14 |
# File 'lib/bsdkrun/types.rb', line 12 def exit_code @exit_code end |
#finished_at ⇒ Object (readonly)
Returns the value of attribute finished_at
12 13 14 |
# File 'lib/bsdkrun/types.rb', line 12 def finished_at @finished_at end |
#id ⇒ String (readonly)
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/bsdkrun/types.rb', line 12 SandboxInfo = Data.define( :id, :name, :image, :kind, :command, :status, :running, :exit_code, :pid, :detached, :cpus, :mem, :volume, :state_dir, :network, :net_ip, :created_at, :finished_at ) do # Map a +ps --json+ row (String keys) to a typed instance. # @param row [Hash] # @return [SandboxInfo] def self.from_row(row) running = !!row["running"] new( id: row["id"].to_s, name: row["name"], image: row["image"].to_s, kind: row["kind"].to_s, command: (row["command"] || "").to_s, status: running ? "running" : "exited", running: running, exit_code: to_i_or_nil(row["exit_code"]), pid: to_i_or_nil(row["pid"]), detached: !!row["detached"], cpus: row["cpus"].to_i, mem: row["mem"].to_i, volume: row["volume"], state_dir: row["state_dir"].to_s, network: row["network"], net_ip: row["net_ip"], created_at: row["created_at"].to_i, finished_at: to_i_or_nil(row["finished_at"]) ) end def self.to_i_or_nil(value) value.nil? ? nil : value.to_i end end |
#image ⇒ Object (readonly)
Returns the value of attribute image
12 13 14 |
# File 'lib/bsdkrun/types.rb', line 12 def image @image end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind
12 13 14 |
# File 'lib/bsdkrun/types.rb', line 12 def kind @kind end |
#mem ⇒ Object (readonly)
Returns the value of attribute mem
12 13 14 |
# File 'lib/bsdkrun/types.rb', line 12 def mem @mem end |
#name ⇒ String? (readonly)
Returns DNS name on a network, or nil if unnamed.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/bsdkrun/types.rb', line 12 SandboxInfo = Data.define( :id, :name, :image, :kind, :command, :status, :running, :exit_code, :pid, :detached, :cpus, :mem, :volume, :state_dir, :network, :net_ip, :created_at, :finished_at ) do # Map a +ps --json+ row (String keys) to a typed instance. # @param row [Hash] # @return [SandboxInfo] def self.from_row(row) running = !!row["running"] new( id: row["id"].to_s, name: row["name"], image: row["image"].to_s, kind: row["kind"].to_s, command: (row["command"] || "").to_s, status: running ? "running" : "exited", running: running, exit_code: to_i_or_nil(row["exit_code"]), pid: to_i_or_nil(row["pid"]), detached: !!row["detached"], cpus: row["cpus"].to_i, mem: row["mem"].to_i, volume: row["volume"], state_dir: row["state_dir"].to_s, network: row["network"], net_ip: row["net_ip"], created_at: row["created_at"].to_i, finished_at: to_i_or_nil(row["finished_at"]) ) end def self.to_i_or_nil(value) value.nil? ? nil : value.to_i end end |
#net_ip ⇒ Object (readonly)
Returns the value of attribute net_ip
12 13 14 |
# File 'lib/bsdkrun/types.rb', line 12 def net_ip @net_ip end |
#network ⇒ Object (readonly)
Returns the value of attribute network
12 13 14 |
# File 'lib/bsdkrun/types.rb', line 12 def network @network end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid
12 13 14 |
# File 'lib/bsdkrun/types.rb', line 12 def pid @pid end |
#running ⇒ Object (readonly)
Returns the value of attribute running
12 13 14 |
# File 'lib/bsdkrun/types.rb', line 12 def running @running end |
#state_dir ⇒ Object (readonly)
Returns the value of attribute state_dir
12 13 14 |
# File 'lib/bsdkrun/types.rb', line 12 def state_dir @state_dir end |
#status ⇒ String (readonly)
Returns "running" or "exited" (derived from running).
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/bsdkrun/types.rb', line 12 SandboxInfo = Data.define( :id, :name, :image, :kind, :command, :status, :running, :exit_code, :pid, :detached, :cpus, :mem, :volume, :state_dir, :network, :net_ip, :created_at, :finished_at ) do # Map a +ps --json+ row (String keys) to a typed instance. # @param row [Hash] # @return [SandboxInfo] def self.from_row(row) running = !!row["running"] new( id: row["id"].to_s, name: row["name"], image: row["image"].to_s, kind: row["kind"].to_s, command: (row["command"] || "").to_s, status: running ? "running" : "exited", running: running, exit_code: to_i_or_nil(row["exit_code"]), pid: to_i_or_nil(row["pid"]), detached: !!row["detached"], cpus: row["cpus"].to_i, mem: row["mem"].to_i, volume: row["volume"], state_dir: row["state_dir"].to_s, network: row["network"], net_ip: row["net_ip"], created_at: row["created_at"].to_i, finished_at: to_i_or_nil(row["finished_at"]) ) end def self.to_i_or_nil(value) value.nil? ? nil : value.to_i end end |
#volume ⇒ Object (readonly)
Returns the value of attribute volume
12 13 14 |
# File 'lib/bsdkrun/types.rb', line 12 def volume @volume end |
Class Method Details
.from_row(row) ⇒ SandboxInfo
Map a ps --json row (String keys) to a typed instance.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/bsdkrun/types.rb', line 20 def self.from_row(row) running = !!row["running"] new( id: row["id"].to_s, name: row["name"], image: row["image"].to_s, kind: row["kind"].to_s, command: (row["command"] || "").to_s, status: running ? "running" : "exited", running: running, exit_code: to_i_or_nil(row["exit_code"]), pid: to_i_or_nil(row["pid"]), detached: !!row["detached"], cpus: row["cpus"].to_i, mem: row["mem"].to_i, volume: row["volume"], state_dir: row["state_dir"].to_s, network: row["network"], net_ip: row["net_ip"], created_at: row["created_at"].to_i, finished_at: to_i_or_nil(row["finished_at"]) ) end |
.to_i_or_nil(value) ⇒ Object
44 45 46 |
# File 'lib/bsdkrun/types.rb', line 44 def self.to_i_or_nil(value) value.nil? ? nil : value.to_i end |