Class: AmberVM::Functions::And

Inherits:
Function show all
Defined in:
lib/amber/functions/logic/and.rb

Overview

The And function is a logical function that gets a number of elements as parameters and executes them untill one of them returns false for is_true?, in that case it stops executing and returns a false Boolean. If all elements are is_true? it returns a true Boolean.

Constant Summary collapse

@@type =
:any

Class Method Summary collapse

Methods inherited from Function

call, data_type, method_missing, signature

Methods included from Plugin

#helper, #included, #plugin_host, #plugin_id, #register_for

Class Method Details

.execargsObject



48
49
50
# File 'lib/amber/functions/logic/and.rb', line 48

def execargs
  false
end

.execute(params, env) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/amber/functions/logic/and.rb', line 35

def execute params, env
  result = AmberVM::Classes::Boolean.new(true)
  while result and not params.empty?
    v =  params.shift
    if result.is_true? and v
      result = v.execute(env)
    else
      return AmberVM::Classes::Boolean.new(false)
    end
  end
  result
end