Class: Nydp::Builtin::Date

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

Instance Method Summary collapse

Methods included from Helper

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

Methods included from Converter

#n2r, #r2n, #rubify

Methods included from Base

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

Instance Method Details

#builtin_call(y = :unset, m = :unset, d = :unset) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/nydp/builtin/date.rb', line 4

def builtin_call y=:unset, m=:unset, d=:unset
  if y == :unset
    Date.today
  elsif m == :unset
    if y.respond_to?(:to_date)
      y.to_date
    elsif y.is_a?(String)
      ::Date.parse(y)
    end
  else
    Date.new(y,m,d)
  end
end