Class: Gitlab::Ci::Pipeline::Expression::Lexeme::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/pipeline/expression/lexeme/base.rb

Direct Known Subclasses

Operator, Value

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build(token) ⇒ Object

Raises:

  • (NotImplementedError)

17
18
19
# File 'lib/gitlab/ci/pipeline/expression/lexeme/base.rb', line 17

def self.build(token)
  raise NotImplementedError
end

.consume?(lexeme) ⇒ Boolean

Returns:

  • (Boolean)

31
32
33
# File 'lib/gitlab/ci/pipeline/expression/lexeme/base.rb', line 31

def self.consume?(lexeme)
  lexeme && precedence >= lexeme.precedence
end

.patternObject


27
28
29
# File 'lib/gitlab/ci/pipeline/expression/lexeme/base.rb', line 27

def self.pattern
  self::PATTERN
end

.scan(scanner) ⇒ Object


21
22
23
24
25
# File 'lib/gitlab/ci/pipeline/expression/lexeme/base.rb', line 21

def self.scan(scanner)
  if scanner.scan(pattern)
    Expression::Token.new(scanner.matched, self)
  end
end

Instance Method Details

#evaluate(**variables) ⇒ Object

Raises:

  • (NotImplementedError)

9
10
11
# File 'lib/gitlab/ci/pipeline/expression/lexeme/base.rb', line 9

def evaluate(**variables)
  raise NotImplementedError
end

#nameObject


13
14
15
# File 'lib/gitlab/ci/pipeline/expression/lexeme/base.rb', line 13

def name
  self.class.name.demodulize.underscore
end