Class: Gitlab::Ci::Pipeline::Expression::Lexeme::Variable
- Inherits:
-
Value
- Object
- Base
- Value
- Gitlab::Ci::Pipeline::Expression::Lexeme::Variable
show all
- Defined in:
- lib/gitlab/ci/pipeline/expression/lexeme/variable.rb
Constant Summary
collapse
- PATTERN =
/\$(?<name>\w+)/
Instance Attribute Summary
Attributes inherited from Value
#value
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Value
#initialize, type
Methods inherited from Base
consume?, #name, pattern, scan
Class Method Details
.build(string) ⇒ Object
23
24
25
|
# File 'lib/gitlab/ci/pipeline/expression/lexeme/variable.rb', line 23
def self.build(string)
new(string.match(PATTERN)[:name])
end
|
Instance Method Details
#evaluate(variables = {}) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/gitlab/ci/pipeline/expression/lexeme/variable.rb', line 11
def evaluate(variables = {})
unless variables.is_a?(ActiveSupport::HashWithIndifferentAccess)
variables = variables.with_indifferent_access
end
variables.fetch(@value, nil)
end
|
#inspect ⇒ Object
19
20
21
|
# File 'lib/gitlab/ci/pipeline/expression/lexeme/variable.rb', line 19
def inspect
"$#{@value}"
end
|