Sha256: ae42505a3d48edbbe7b480dca2e78e131fa3543f35e8eccd30856114834a424f

Contents?: true

Size: 508 Bytes

Versions: 11

Compression:

Stored size: 508 Bytes

Contents

require_relative '../function'

module Dentaku
  module AST
    class Count < Function
      def self.min_param_count
        0
      end

      def self.max_param_count
        Float::INFINITY
      end

      def value(context = {})
        if @args.length == 1
          first_arg = @args[0].value(context)
          return first_arg.length if first_arg.respond_to?(:length)
        end

        @args.length
      end
    end
  end
end

Dentaku::AST::Function.register_class(:count, Dentaku::AST::Count)

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
dentaku-3.5.4 lib/dentaku/ast/functions/count.rb
dentaku-3.5.3 lib/dentaku/ast/functions/count.rb
dentaku-3.5.2 lib/dentaku/ast/functions/count.rb
dentaku_zevo-3.5.2 lib/dentaku/ast/functions/count.rb
dentaku-3.5.1 lib/dentaku/ast/functions/count.rb
dentaku-3.5.0 lib/dentaku/ast/functions/count.rb
dentaku-3.4.2 lib/dentaku/ast/functions/count.rb
dentaku-3.4.1 lib/dentaku/ast/functions/count.rb
dentaku-3.4.0 lib/dentaku/ast/functions/count.rb
dentaku-3.3.4 lib/dentaku/ast/functions/count.rb
dentaku-3.3.3 lib/dentaku/ast/functions/count.rb