Module: Nydp::Builtin::Base
- Includes:
- Helper
- Included in:
- Abs, Apply, CdrSet, Comment, Date, Divide, Ensuring, Error, Eval, GreaterThan, HandleError, Hash, HashGet, HashKeyPresent, HashKeys, HashMerge, HashSet, HashSlice, HashToArray, Inspect, IsEqual, LessThan, Log, MathCeiling, MathFloor, MathPower, MathRound, Minus, Parse, ParseInString, Plus, PreCompile, Puts, Quit, RNG, Rand, RandomString, ScriptRun, SetIntersection, SetUnion, Sort, StringLength, StringMatch, StringReplace, StringSplit, Sym, ThreadLocals, Time, Times, ToInteger, ToString, TypeOf, VmInfo, Random
- Defined in:
- lib/nydp/builtin.rb
Constant Summary
collapse
- @@reraise_errors =
[]
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Helper
#cons, #list, #literal?, #pair?, #sig, #sym, #sym?
Methods included from Converter
#n2r, #r2n, #rubify
Class Method Details
.ignore_errors(kla) ⇒ Object
6
7
8
|
# File 'lib/nydp/builtin.rb', line 6
def self.ignore_errors kla
@@reraise_errors << kla
end
|
Instance Method Details
#call(*args) ⇒ Object
Also known as:
_nydp_call
23
24
25
26
27
|
# File 'lib/nydp/builtin.rb', line 23
def call *args
builtin_call *args
rescue => e
handle_error e, *args
end
|
#handle_error(e, *args) ⇒ Object
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/nydp/builtin.rb', line 12
def handle_error e, *args
case e
when *@@reraise_errors
raise e
else
arg_msg = args.map { |a| "#{a._nydp_inspect}"}.join("\n").split(/\n/).map { |s| " #{s}"}.join("\n")
new_msg = "Called #{self._nydp_inspect}\nwith args\n#{arg_msg}"
raise new_msg
end
end
|
38
|
# File 'lib/nydp/builtin.rb', line 38
def inspect ; "builtin/#{name}" ; end
|
31
32
33
34
35
36
|
# File 'lib/nydp/builtin.rb', line 31
def name
cname = self.class.name.split("::").last
cname = cname.gsub(/([a-z])([A-Z])/) { |m| "#{m[0]}-#{m[1].downcase}" }
cname = cname.gsub(/^([A-Z])/) { |m| m.downcase }
cname
end
|
#nydp_type ⇒ Object
40
|
# File 'lib/nydp/builtin.rb', line 40
def nydp_type ; "fn" ; end
|
39
|
# File 'lib/nydp/builtin.rb', line 39
def to_s ; name ; end
|