Sha256: d5471dc063839d0cf60e00f1555c3080339d73491893d0e9131d604813ffdb0c

Contents?: true

Size: 390 Bytes

Versions: 5

Compression:

Stored size: 390 Bytes

Contents

require_relative '../function'

module Dentaku
  module AST
    class Count < Function
      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

5 entries across 5 versions & 1 rubygems

Version Path
dentaku-3.3.2 lib/dentaku/ast/functions/count.rb
dentaku-3.3.1 lib/dentaku/ast/functions/count.rb
dentaku-3.3.0 lib/dentaku/ast/functions/count.rb
dentaku-3.2.1 lib/dentaku/ast/functions/count.rb
dentaku-3.2.0 lib/dentaku/ast/functions/count.rb