Class: Microsandbox::SandboxInfo
- Inherits:
-
Object
- Object
- Microsandbox::SandboxInfo
- Defined in:
- lib/microsandbox/sandbox.rb
Overview
Lightweight metadata about a sandbox, returned by Microsandbox::Sandbox.get and Microsandbox::Sandbox.list. This is a snapshot, not a live handle.
Instance Attribute Summary collapse
- #name ⇒ String readonly
-
#status ⇒ Symbol
readonly
:running, :draining, :paused, :stopped, or :crashed.
Instance Method Summary collapse
- #created_at ⇒ Time?
-
#initialize(data) ⇒ SandboxInfo
constructor
A new instance of SandboxInfo.
- #inspect ⇒ Object
- #running? ⇒ Boolean
- #stopped? ⇒ Boolean
- #updated_at ⇒ Time?
Constructor Details
#initialize(data) ⇒ SandboxInfo
Returns a new instance of SandboxInfo.
12 13 14 15 16 17 |
# File 'lib/microsandbox/sandbox.rb', line 12 def initialize(data) @name = data["name"] @status = data["status"].to_sym @created_at_ms = data["created_at_ms"] @updated_at_ms = data["updated_at_ms"] end |
Instance Attribute Details
#name ⇒ String (readonly)
8 9 10 |
# File 'lib/microsandbox/sandbox.rb', line 8 def name @name end |
#status ⇒ Symbol (readonly)
Returns :running, :draining, :paused, :stopped, or :crashed.
10 11 12 |
# File 'lib/microsandbox/sandbox.rb', line 10 def status @status end |
Instance Method Details
#created_at ⇒ Time?
23 24 25 |
# File 'lib/microsandbox/sandbox.rb', line 23 def created_at @created_at_ms && Time.at(@created_at_ms / 1000.0) end |
#inspect ⇒ Object
32 33 34 |
# File 'lib/microsandbox/sandbox.rb', line 32 def inspect "#<Microsandbox::SandboxInfo name=#{@name.inspect} status=#{@status}>" end |
#running? ⇒ Boolean
19 |
# File 'lib/microsandbox/sandbox.rb', line 19 def running? = @status == :running |
#stopped? ⇒ Boolean
20 |
# File 'lib/microsandbox/sandbox.rb', line 20 def stopped? = @status == :stopped |
#updated_at ⇒ Time?
28 29 30 |
# File 'lib/microsandbox/sandbox.rb', line 28 def updated_at @updated_at_ms && Time.at(@updated_at_ms / 1000.0) end |