Module: Travis::Conditions::V1::Boolean

Included in:
Parser
Defined in:
lib/travis/conditions/v1/boolean.rb

Constant Summary collapse

AND =
/(and|&&)/i
OR =
/(or|\|\|)/i
NOT =
/(not|!)/i
BOP =
{
  'and' => :and,
  '&&'  => :and,
  'or'  => :or,
  '||'  => :and,
  'not' => :not
}

Instance Method Summary collapse

Instance Method Details

#exprObject



39
40
41
42
43
# File 'lib/travis/conditions/v1/boolean.rb', line 39

def expr
  lft = expr_
  lft = [:or, lft, expr_] while op(OR)
  lft
end

#expr_Object



45
46
47
48
49
# File 'lib/travis/conditions/v1/boolean.rb', line 45

def expr_
  lft = oprd
  lft = [:and, lft, oprd] while op(AND)
  lft
end

#not_Object



57
58
59
60
61
62
63
# File 'lib/travis/conditions/v1/boolean.rb', line 57

def not_
  pos = self.pos
  space { scan(NOT) } or return
  t = yield and return [:not, t]
  str.pos = pos
  nil
end

#op(op) ⇒ Object



65
66
67
# File 'lib/travis/conditions/v1/boolean.rb', line 65

def op(op)
  op = space { scan(op) } and BOP[op.downcase]
end

#oprdObject



51
52
53
54
55
# File 'lib/travis/conditions/v1/boolean.rb', line 51

def oprd
  t = parens { expr } and return t
  t = not_ { oprd } and return t
  term
end