Class: Indocker::DockerDirectives::From

Inherits:
Base show all
Defined in:
lib/indocker/directives/docker_directives/from.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#args

Instance Method Summary collapse

Methods inherited from Indocker::Directives::Base

#build_directive?, #container_directive?, #partial?, #prepare_directive?

Constructor Details

#initialize(repo_tag, tag: nil) ⇒ From

Returns a new instance of From.



4
5
6
7
8
9
10
11
12
13
# File 'lib/indocker/directives/docker_directives/from.rb', line 4

def initialize(repo_tag, tag: nil)
  case repo_tag
  when String
    @repo = repo_tag.split(':')[0]
    @tag  = tag || repo_tag.split(':')[1] || Indocker::ImageMetadata::DEFAULT_TAG
  else
    @repo = repo_tag
    @tag  = tag || Indocker::ImageMetadata::DEFAULT_TAG
  end
end

Instance Attribute Details

#repo ⇒ Object (readonly)

Returns the value of attribute repo.



2
3
4
# File 'lib/indocker/directives/docker_directives/from.rb', line 2

def repo
  @repo
end

#tag ⇒ Object (readonly)

Returns the value of attribute tag.



2
3
4
# File 'lib/indocker/directives/docker_directives/from.rb', line 2

def tag
  @tag
end

Instance Method Details

#dockerhub_image? ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/indocker/directives/docker_directives/from.rb', line 19

def dockerhub_image?
  repo.is_a?(String)
end

#full_name ⇒ Object



15
16
17
# File 'lib/indocker/directives/docker_directives/from.rb', line 15

def full_name
  "#{repo}:#{tag}"
end

#to_s ⇒ Object



23
24
25
# File 'lib/indocker/directives/docker_directives/from.rb', line 23

def to_s
  "#{type} #{repo}:#{tag}"
end

#type ⇒ Object



27
28
29
# File 'lib/indocker/directives/docker_directives/from.rb', line 27

def type
  'FROM'
end