Class: Matrixeval::Variant

Inherits:
Object
  • Object
show all
Defined in:
lib/matrixeval/variant.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}, vector) ⇒ Variant

Returns a new instance of Variant.

Raises:



11
12
13
14
15
16
17
18
19
20
# File 'lib/matrixeval/variant.rb', line 11

def initialize(config = {}, vector)
  raise Error.new("Variant#key is missing") if config["key"].nil?

  @vector = vector
  @key = config["key"].to_s
  @container = Container.new(config["container"])
  @env = config["env"] || {}
  @default = config["default"] || false
  @mounts = config["mounts"] || []
end

Instance Attribute Details

#containerObject (readonly)

Returns the value of attribute container.



9
10
11
# File 'lib/matrixeval/variant.rb', line 9

def container
  @container
end

#defaultObject (readonly)

Returns the value of attribute default.



9
10
11
# File 'lib/matrixeval/variant.rb', line 9

def default
  @default
end

#envObject (readonly)

Returns the value of attribute env.



9
10
11
# File 'lib/matrixeval/variant.rb', line 9

def env
  @env
end

#keyObject (readonly)

Returns the value of attribute key.



9
10
11
# File 'lib/matrixeval/variant.rb', line 9

def key
  @key
end

#mountsObject (readonly)

Returns the value of attribute mounts.



9
10
11
# File 'lib/matrixeval/variant.rb', line 9

def mounts
  @mounts
end

#vectorObject (readonly)

Returns the value of attribute vector.



9
10
11
# File 'lib/matrixeval/variant.rb', line 9

def vector
  @vector
end

Class Method Details

.default(key, vector) ⇒ Object



4
5
6
# File 'lib/matrixeval/variant.rb', line 4

def default(key, vector)
  self.new({"key" => key}, vector)
end

Instance Method Details

#==(variant) ⇒ Object



46
47
48
49
# File 'lib/matrixeval/variant.rb', line 46

def ==(variant)
  vector.key == variant.vector.key &&
    key == variant.key
end

#default?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/matrixeval/variant.rb', line 38

def default?
  default
end

#docker_compose_service_nameObject



30
31
32
# File 'lib/matrixeval/variant.rb', line 30

def docker_compose_service_name
  id
end

#idObject



26
27
28
# File 'lib/matrixeval/variant.rb', line 26

def id
  "#{vector.id}_#{key.to_s.gsub(/[^A-Za-z0-9]/,'_')}"
end

#match_command_options?(options) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/matrixeval/variant.rb', line 42

def match_command_options?(options)
  options[vector.key] == key.to_s
end

#nameObject



22
23
24
# File 'lib/matrixeval/variant.rb', line 22

def name
  "#{vector.key}: #{key}"
end

#pathnameObject



34
35
36
# File 'lib/matrixeval/variant.rb', line 34

def pathname
  id
end