Class: Nydp::Builtin::ToInteger

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

Instance Method Summary collapse

Methods included from Base

#call, #handle_error, ignore_errors, #inspect, #name, #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(arg) ⇒ Object



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

def builtin_call arg
  arg = n2r arg

  if arg.respond_to? :to_i
    arg.to_i
  elsif arg.respond_to? :to_time
    arg.to_time.to_i
  else
    arg.to_s.to_i
  end
end