Class: Docker::Asset

Inherits:
Object
  • Object
show all
Defined in:
lib/docker/asset.rb

Overview

Base class for containers, images and other Docker assets.

Direct Known Subclasses

Container

Instance Method Summary collapse

Constructor Details

#initialize(json, session: nil) ⇒ Asset

Returns a new instance of Asset.



4
5
6
7
8
# File 'lib/docker/asset.rb', line 4

def initialize(json, session:nil)
  json = JSON.load(json) if json.is_a?(String)
  @json = json
  @session = session
end

Instance Method Details

#inspectObject



10
11
12
# File 'lib/docker/asset.rb', line 10

def inspect
  %Q{#<#{self.class.name}:#{self.name}>}
end

#nameString

Returns human-readable name of container, image or volume.

Returns:

  • (String)

    human-readable name of container, image or volume



15
16
17
# File 'lib/docker/asset.rb', line 15

def name
  @json['Name']
end

#to_hObject



19
20
21
# File 'lib/docker/asset.rb', line 19

def to_h
  @json
end

#to_sObject



23
24
25
# File 'lib/docker/asset.rb', line 23

def to_s
  self.inspect
end