Class: Gitlab::Ci::Config::Interpolation::Block
- Inherits:
-
Object
- Object
- Gitlab::Ci::Config::Interpolation::Block
- Defined in:
- lib/gitlab/ci/config/interpolation/block.rb
Overview
This class represents an interpolation block. The format supported is: $[[ <access> | <function1> | <function2> | … <functionN> ]]
<access> specifies the value to retrieve (e.g. ‘inputs.key`). <function> can be optionally provided with or without arguments to manipulate the access value. Functions are evaluated in the order they are presented.
Constant Summary collapse
- MAX_FUNCTIONS =
3
Instance Attribute Summary collapse
-
#ctx ⇒ Object
readonly
Returns the value of attribute ctx.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(block, data, ctx) ⇒ Block
constructor
A new instance of Block.
- #length ⇒ Object
- #to_s ⇒ Object
- #valid? ⇒ Boolean
- #value ⇒ Object
Constructor Details
#initialize(block, data, ctx) ⇒ Block
Returns a new instance of Block.
20 21 22 23 24 25 26 27 28 |
# File 'lib/gitlab/ci/config/interpolation/block.rb', line 20 def initialize(block, data, ctx) @block = block @data = data @ctx = ctx @errors = [] @value = nil evaluate! end |
Instance Attribute Details
#ctx ⇒ Object (readonly)
Returns the value of attribute ctx.
18 19 20 |
# File 'lib/gitlab/ci/config/interpolation/block.rb', line 18 def ctx @ctx end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
18 19 20 |
# File 'lib/gitlab/ci/config/interpolation/block.rb', line 18 def data @data end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
18 19 20 |
# File 'lib/gitlab/ci/config/interpolation/block.rb', line 18 def errors @errors end |
Instance Method Details
#content ⇒ Object
34 35 36 |
# File 'lib/gitlab/ci/config/interpolation/block.rb', line 34 def content data end |
#length ⇒ Object
44 45 46 |
# File 'lib/gitlab/ci/config/interpolation/block.rb', line 44 def length block.length end |
#to_s ⇒ Object
48 49 50 |
# File 'lib/gitlab/ci/config/interpolation/block.rb', line 48 def to_s block end |
#valid? ⇒ Boolean
30 31 32 |
# File 'lib/gitlab/ci/config/interpolation/block.rb', line 30 def valid? errors.none? end |
#value ⇒ Object
38 39 40 41 42 |
# File 'lib/gitlab/ci/config/interpolation/block.rb', line 38 def value raise ArgumentError, 'block invalid' unless valid? @value end |