Class: Gitlab::Ci::Config::Yaml::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/config/yaml/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config: nil, error: nil, error_class: nil, interpolated: false) ⇒ Result

Returns a new instance of Result.



10
11
12
13
14
15
# File 'lib/gitlab/ci/config/yaml/result.rb', line 10

def initialize(config: nil, error: nil, error_class: nil, interpolated: false)
  @config = Array.wrap(config)
  @error = error
  @error_class = error_class
  @interpolated = interpolated
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



8
9
10
# File 'lib/gitlab/ci/config/yaml/result.rb', line 8

def error
  @error
end

#error_classObject (readonly)

Returns the value of attribute error_class.



8
9
10
# File 'lib/gitlab/ci/config/yaml/result.rb', line 8

def error_class
  @error_class
end

Instance Method Details

#contentObject



37
38
39
40
41
# File 'lib/gitlab/ci/config/yaml/result.rb', line 37

def content
  return @config.last if has_header?

  @config.first || {}
end

#has_header?Boolean

Returns:

  • (Boolean)


25
26
27
28
29
# File 'lib/gitlab/ci/config/yaml/result.rb', line 25

def has_header?
  return false unless @config.first.is_a?(Hash)

  @config.size > 1 && @config.first.key?(:spec)
end

#headerObject

Raises:

  • (ArgumentError)


31
32
33
34
35
# File 'lib/gitlab/ci/config/yaml/result.rb', line 31

def header
  raise ArgumentError unless has_header?

  @config.first
end

#interpolated?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/gitlab/ci/config/yaml/result.rb', line 21

def interpolated?
  !!@interpolated
end

#valid?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/gitlab/ci/config/yaml/result.rb', line 17

def valid?
  error.nil?
end