Sha256: 74b8bd4746bc4a9a9a6230b7beb8e4d7c511301a8ef79295842a3d7136d08653

Contents?: true

Size: 639 Bytes

Versions: 15

Compression:

Stored size: 639 Bytes

Contents

require_relative '../function'
require_relative '../../exceptions'

Dentaku::AST::Function.register(:or, :logical, lambda { |*args|
  if args.empty?
    raise Dentaku::ArgumentError.for(
      :too_few_arguments,
      function_name: 'OR()', at_least: 1, given: 0
    ), 'OR() requires at least one argument'
  end

  args.any? do |arg|
    case arg
    when TrueClass
      true
    when FalseClass, nil
      false
    else
      raise Dentaku::ArgumentError.for(
        :incompatible_type,
        function_name: 'OR()', expect: :logical, actual: arg.class
      ), 'OR() requires arguments to be logical expressions'
    end
  end
})

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
dentaku-3.5.4 lib/dentaku/ast/functions/or.rb
dentaku-3.5.3 lib/dentaku/ast/functions/or.rb
dentaku-3.5.2 lib/dentaku/ast/functions/or.rb
dentaku_zevo-3.5.2 lib/dentaku/ast/functions/or.rb
dentaku-3.5.1 lib/dentaku/ast/functions/or.rb
dentaku-3.5.0 lib/dentaku/ast/functions/or.rb
dentaku-3.4.2 lib/dentaku/ast/functions/or.rb
dentaku-3.4.1 lib/dentaku/ast/functions/or.rb
dentaku-3.4.0 lib/dentaku/ast/functions/or.rb
dentaku-3.3.4 lib/dentaku/ast/functions/or.rb
dentaku-3.3.3 lib/dentaku/ast/functions/or.rb
dentaku-3.3.2 lib/dentaku/ast/functions/or.rb
dentaku-3.3.1 lib/dentaku/ast/functions/or.rb
dentaku-3.3.0 lib/dentaku/ast/functions/or.rb
dentaku-3.2.1 lib/dentaku/ast/functions/or.rb