Class: Nydp::Builtin::Plus

Inherits:
Object show all
Includes:
Base, Singleton
Defined in:
lib/nydp/builtin/plus.rb

Instance Method Summary collapse

Methods included from Base

#call, #handle_error, ignore_errors, #inspect, #nydp_type, #to_s

Methods included from Helper

#cons, #list, #literal?, #pair?, #sig, #sym, #sym?

Methods included from Converter

#n2r, #r2n, #rubify

Instance Method Details

#builtin_call(*args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/nydp/builtin/plus.rb', line 6

def builtin_call *args
  if args.empty?
    0
  else
    case args.first
    when String
      args.each_with_object("") { |str, res| res << str.to_s }
    when Date
      (args.shift._nydp_date + builtin_call(*args)).to_ruby
    else
      args.reduce &:+
    end
  end._nydp_wrapper
end

#nameObject



4
# File 'lib/nydp/builtin/plus.rb', line 4

def name ; "+" ; end