Class: Bsdkrun::DockerContainer

Inherits:
Data
  • Object
show all
Defined in:
lib/bsdkrun/types.rb

Overview

A container in the Docker engine VM — a trimmed docker ps row.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command

Returns:

  • (Object)

    the current value of command



255
256
257
# File 'lib/bsdkrun/types.rb', line 255

def command
  @command
end

#createdObject (readonly)

Returns the value of attribute created

Returns:

  • (Object)

    the current value of created



255
256
257
# File 'lib/bsdkrun/types.rb', line 255

def created
  @created
end

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



255
256
257
# File 'lib/bsdkrun/types.rb', line 255

def id
  @id
end

#imageObject (readonly)

Returns the value of attribute image

Returns:

  • (Object)

    the current value of image



255
256
257
# File 'lib/bsdkrun/types.rb', line 255

def image
  @image
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



255
256
257
# File 'lib/bsdkrun/types.rb', line 255

def name
  @name
end

#portsObject (readonly)

Returns the value of attribute ports

Returns:

  • (Object)

    the current value of ports



255
256
257
# File 'lib/bsdkrun/types.rb', line 255

def ports
  @ports
end

#stateObject (readonly)

Returns the value of attribute state

Returns:

  • (Object)

    the current value of state



255
256
257
# File 'lib/bsdkrun/types.rb', line 255

def state
  @state
end

#statusObject (readonly)

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



255
256
257
# File 'lib/bsdkrun/types.rb', line 255

def status
  @status
end

Class Method Details

.from_graphql(c) ⇒ DockerContainer Also known as: from_row

Both the GraphQL object and docker ps --json use these field names.

Parameters:

  • c (Hash)

Returns:



266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/bsdkrun/types.rb', line 266

def self.from_graphql(c)
  new(
    id: c["id"].to_s,
    name: c["name"].to_s,
    image: c["image"].to_s,
    command: (c["command"] || "").to_s,
    state: c["state"].to_s,
    status: c["status"].to_s,
    ports: Array(c["ports"]),
    created: c["created"].to_i
  )
end

Instance Method Details

#running?Boolean

Returns whether the container is up.

Returns:

  • (Boolean)

    whether the container is up.



259
260
261
# File 'lib/bsdkrun/types.rb', line 259

def running?
  state == "running"
end