nydp 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/lib/lisp/core-012-utils.nydp +19 -5
  3. data/lib/lisp/core-015-documentation.nydp +6 -3
  4. data/lib/lisp/core-017-builtin-dox.nydp +35 -30
  5. data/lib/lisp/core-030-syntax.nydp +24 -23
  6. data/lib/lisp/core-035-flow-control.nydp +3 -3
  7. data/lib/lisp/core-037-list-utils.nydp +24 -14
  8. data/lib/lisp/core-040-utils.nydp +22 -14
  9. data/lib/lisp/core-041-string-utils.nydp +12 -8
  10. data/lib/lisp/core-043-list-utils.nydp +3 -9
  11. data/lib/lisp/core-045-dox-utils.nydp +5 -0
  12. data/lib/lisp/core-100-utils.nydp +27 -12
  13. data/lib/lisp/core-110-hash-utils.nydp +7 -0
  14. data/lib/lisp/core-120-settings.nydp +35 -0
  15. data/lib/lisp/{core-060-benchmarking.nydp → core-900-benchmarking.nydp} +47 -17
  16. data/lib/lisp/tests/cdr-set-examples.nydp +6 -0
  17. data/lib/lisp/tests/date-examples.nydp +2 -0
  18. data/lib/lisp/tests/foundation-test.nydp +12 -0
  19. data/lib/lisp/tests/hash-examples.nydp +1 -1
  20. data/lib/lisp/tests/set-intersection-examples.nydp +16 -0
  21. data/lib/lisp/tests/set-union-examples.nydp +8 -0
  22. data/lib/lisp/tests/settings-examples.nydp +24 -0
  23. data/lib/lisp/tests/sort-examples.nydp +8 -0
  24. data/lib/lisp/tests/string-tests.nydp +9 -0
  25. data/lib/lisp/tests/zap-examples.nydp +12 -0
  26. data/lib/nydp.rb +3 -4
  27. data/lib/nydp/builtin/cdr_set.rb +1 -6
  28. data/lib/nydp/builtin/handle_error.rb +1 -1
  29. data/lib/nydp/builtin/hash.rb +3 -44
  30. data/lib/nydp/core_ext.rb +41 -0
  31. data/lib/nydp/date.rb +18 -20
  32. data/lib/nydp/hash.rb +5 -6
  33. data/lib/nydp/helper.rb +9 -25
  34. data/lib/nydp/string_atom.rb +14 -19
  35. data/lib/nydp/symbol.rb +40 -27
  36. data/lib/nydp/truth.rb +9 -2
  37. data/lib/nydp/version.rb +1 -1
  38. data/lib/nydp/vm.rb +0 -2
  39. data/spec/date_spec.rb +22 -22
  40. data/spec/hash_non_hash_behaviour_spec.rb +2 -2
  41. data/spec/spec_helper.rb +4 -1
  42. data/spec/symbol_spec.rb +31 -0
  43. data/spec/time_spec.rb +1 -1
  44. metadata +9 -3
@@ -0,0 +1,7 @@
1
+ (chapter-start 'hash-manipulation "utilities for manipulating, accessing and altering hash objects")
2
+
3
+ ; return values for each key in hash 'h
4
+ (def hash-values (h) (map (fn (k) h.,k) (hash-keys h)))
5
+
6
+ ; (auto-hash a b c) same as { a a b b c c }
7
+ (mac auto-hash names `(brace-list ,@(flatten:map λn(list n n) names)))
@@ -0,0 +1,35 @@
1
+ (chapter-start 'settings "Utilities for managing settings")
2
+
3
+ (assign settings {})
4
+
5
+ ; convert expr to a function that returns the expr, unless expr is a symbol in which case we assume it already refers to a fn
6
+ (def settings/fn (expr)
7
+ (if (sym? expr) expr
8
+ (or (atom? expr) (no expr)) `(k ,expr)
9
+ `(fn (_) ,expr)))
10
+
11
+ ; update value of setting 'name
12
+ (mac set-setting (name value)
13
+ `(do (hash-cons (dox-item-by-type 'setting ',(sym name))
14
+ 'values
15
+ { plugin this-plugin script this-script value ',value })
16
+ (hash-set settings ',(sym name) ,(settings/fn value))))
17
+
18
+ (mac def-setting (name initial)
19
+ ; define a setting in the given 'context with a 'name and an 'initial value, with a 'doc to explain it
20
+ ; if value is a function, it is invoked with 'context and 'name to retrieve its value
21
+ ; if value is a constant, it is wrapped in a function to return the constant
22
+ (let context (car:string-split name ".")
23
+ `(do (dox-add-doc ',(sym name)
24
+ 'setting
25
+ ',(fetch-and-clear-comments)
26
+ nil
27
+ '(def-setting ,name ,initial)
28
+ '(,(sym "settings/~context"))
29
+ { setting { default ',initial context ',context name ',name } })
30
+ (set-setting ,(sym name) ,initial))))
31
+
32
+ ; get the value of the given setting
33
+ (def setting (name)
34
+ (on-err (error "can't get value of setting ~name")
35
+ ((hash-get settings (sym name)) name)))
@@ -159,21 +159,49 @@
159
159
  ;; (= h.ca v1) (= h.cb v2) (= h.cc v3) (= h.ca v4) (= h.cb v5) (= h.cc v6)
160
160
  ;; (= h.da v1) (= h.db v2) (= h.dc v3) (= h.da v4) (= h.db v5) (= h.dc v6)))
161
161
 
162
- (def bm-or-lex-lex-lex (a b c) (or a b c))
163
- (def bm-faster-or ()
164
- (bm-or-lex-lex-lex 1 2 3)
165
- (bm-or-lex-lex-lex nil 2 3))
166
-
167
- (def build-mapsum-data (count data)
168
- (if (> count 0)
169
- (build-mapsum-data (- count 1)
170
- (cons { mappit (rand 10) }
171
- data))
172
- data))
173
-
174
- (let mapsum-data (build-mapsum-data 1000)
175
- (def bm-mapsum () (mapsum &mappit mapsum-data))
176
- (def bm-mapreduce () (mapreduce &mappit + mapsum-data 0)))
162
+ ;; (def bm-acc ()
163
+ ;; (accum z
164
+ ;; (z 0) (z 1) (z 2) (z 3) (z 4) (z 5) (z 6) (z 7) (z 8) (z 9)
165
+ ;; (z 0) (z 1) (z 2) (z 3) (z 4) (z 5) (z 6) (z 7) (z 8) (z 9)
166
+ ;; (z 0) (z 1) (z 2) (z 3) (z 4) (z 5) (z 6) (z 7) (z 8) (z 9)
167
+ ;; (z 0) (z 1) (z 2) (z 3) (z 4) (z 5) (z 6) (z 7) (z 8) (z 9)
168
+ ;; (z 0) (z 1) (z 2) (z 3) (z 4) (z 5) (z 6) (z 7) (z 8) (z 9)
169
+ ;; (z 0) (z 1) (z 2) (z 3) (z 4) (z 5) (z 6) (z 7) (z 8) (z 9)
170
+ ;; (z 0) (z 1) (z 2) (z 3) (z 4) (z 5) (z 6) (z 7) (z 8) (z 9)
171
+ ;; (z 0) (z 1) (z 2) (z 3) (z 4) (z 5) (z 6) (z 7) (z 8) (z 9)
172
+ ;; (z 0) (z 1) (z 2) (z 3) (z 4) (z 5) (z 6) (z 7) (z 8) (z 9)))
173
+
174
+ ;; (def bm-facc ()
175
+ ;; (faccum z
176
+ ;; (z 0) (z 1) (z 2) (z 3) (z 4) (z 5) (z 6) (z 7) (z 8) (z 9)
177
+ ;; (z 0) (z 1) (z 2) (z 3) (z 4) (z 5) (z 6) (z 7) (z 8) (z 9)
178
+ ;; (z 0) (z 1) (z 2) (z 3) (z 4) (z 5) (z 6) (z 7) (z 8) (z 9)
179
+ ;; (z 0) (z 1) (z 2) (z 3) (z 4) (z 5) (z 6) (z 7) (z 8) (z 9)
180
+ ;; (z 0) (z 1) (z 2) (z 3) (z 4) (z 5) (z 6) (z 7) (z 8) (z 9)
181
+ ;; (z 0) (z 1) (z 2) (z 3) (z 4) (z 5) (z 6) (z 7) (z 8) (z 9)
182
+ ;; (z 0) (z 1) (z 2) (z 3) (z 4) (z 5) (z 6) (z 7) (z 8) (z 9)
183
+ ;; (z 0) (z 1) (z 2) (z 3) (z 4) (z 5) (z 6) (z 7) (z 8) (z 9)
184
+ ;; (z 0) (z 1) (z 2) (z 3) (z 4) (z 5) (z 6) (z 7) (z 8) (z 9)))
185
+
186
+ (in-private
187
+ (def bm-j ()
188
+ (j "abc" '(d e f (g h i)) (list "jk" "lm")))
189
+
190
+ (def bm-or-lex-lex-lex (a b c) (or a b c))
191
+ (def bm-faster-or ()
192
+ (bm-or-lex-lex-lex 1 2 3)
193
+ (bm-or-lex-lex-lex nil 2 3))
194
+
195
+ (def build-mapsum-data (count data)
196
+ (if (> count 0)
197
+ (build-mapsum-data (- count 1)
198
+ (cons { mappit (rand 10) }
199
+ data))
200
+ data))
201
+
202
+ (let mapsum-data (build-mapsum-data 1000)
203
+ (def bm-mapsum () (mapsum &mappit mapsum-data))
204
+ (def bm-mapreduce () (mapreduce &mappit + mapsum-data 0))))
177
205
 
178
206
 
179
207
 
@@ -197,8 +225,10 @@
197
225
 
198
226
  (def rbs (name)
199
227
  (let summary nil
200
- (push (bm "mapsum " bm-mapsum 10 100) summary)
201
- (push (bm "mapreduce " bm-mapreduce 10 100) summary)
228
+ ;; (push (bm "accum " bm-acc 10 500) summary)
229
+ ;; (push (bm "accum " bm-facc 10 500) summary)
230
+ ;; (push (bm "mapsum " bm-mapsum 10 100) summary)
231
+ ;; (push (bm "mapreduce " bm-mapreduce 10 100) summary)
202
232
  ;; (push (bm "cond with OR " bm-faster-or 10 40000) summary)
203
233
  ;; (push (bm "cond with OR " bm-cond-9 10 40000) summary)
204
234
  ;; (push (bm "cond with OR " bm-cond-9 10 100000) summary)
@@ -0,0 +1,6 @@
1
+ (examples-for cdr-set
2
+ ("sets cdr of a cons cell"
3
+ (let things '(a b c d)
4
+ (cdr-set things '(x y z))
5
+ things)
6
+ (a x y z)))
@@ -18,6 +18,8 @@
18
18
  ("navigates to week end from sun" (let d (date 2015 11 1) (to-string d.end-of-week)) "2015-11-01" )
19
19
  ("navigates to week end" (let d (date 2015 11 6) (to-string d.end-of-week)) "2015-11-08" )
20
20
 
21
+ ("parses string" (let d (date "2004-03-12") (list d.year d.month d.day)) (2004 3 12))
22
+
21
23
  ("can act as hash key"
22
24
  (with (h {} d (date 2015 11 8))
23
25
  (hash-set h d "on this day")
@@ -169,3 +169,15 @@
169
169
  ("argument default value is nil"
170
170
  ( (fn (x y z) (list x y (car z))) 'a 'b )
171
171
  (a b nil)))
172
+
173
+ (examples-for do
174
+ ("executes its content"
175
+ (let premesolithic 3
176
+ (do
177
+ (assign premesolithic (* premesolithic 4))
178
+ (let jurassic 17
179
+ (do
180
+ (= jurassic (+ jurassic premesolithic))
181
+ (= premesolithic (+ jurassic premesolithic))
182
+ (* premesolithic 2)))))
183
+ 82))
@@ -28,7 +28,7 @@
28
28
  ("returns nil for a symbol" (hash-keys 'lipstick) nil)
29
29
 
30
30
  ("returns date operations"
31
- (hash-keys (date 2015 11 18))
31
+ (sort:hash-keys (date 2015 11 18))
32
32
  (beginning_of_month
33
33
  beginning_of_week
34
34
  beginning_of_year
@@ -3,14 +3,30 @@
3
3
  (⋂ '(a b c))
4
4
  (a b c))
5
5
 
6
+ ("returns a single nil arg"
7
+ (⋂ nil)
8
+ nil)
9
+
6
10
  ("returns intersection of two args"
7
11
  (⋂ '(a b c) '(a b d))
8
12
  (a b))
9
13
 
14
+ ("returns intersection of list and nil"
15
+ (⋂ '(a b c) nil)
16
+ nil)
17
+
18
+ ("returns intersection of nil and list"
19
+ (⋂ nil '(a b c))
20
+ nil)
21
+
10
22
  ("returns intersection of three args"
11
23
  (⋂ '(a b c d e) '(a b c d f) '(z b c d g))
12
24
  (b c d))
13
25
 
26
+ ("returns intersection of list, nil, and another list"
27
+ (⋂ '(a b c d e) nil '(z b c d g))
28
+ nil)
29
+
14
30
  ("returns intersection of four args"
15
31
  (⋂ '(a b c d e) '(a b c d f) '(z b d c g) '(z y g c d))
16
32
  (c d)))
@@ -7,10 +7,18 @@
7
7
  (⋃ '(a b c) '(a b d))
8
8
  (a b c d))
9
9
 
10
+ ("returns union of arg and nil"
11
+ (⋃ '(a b c) nil)
12
+ (a b c))
13
+
10
14
  ("returns union of three args"
11
15
  (⋃ '(a b c d e) '(a b c d f) '(z b c d g))
12
16
  (a b c d e f z g))
13
17
 
18
+ ("returns union of arg nil arg"
19
+ (⋃ '(a b c d e) nil '(z b c d g))
20
+ (a b c d e z g))
21
+
14
22
  ("returns union of four args"
15
23
  (⋃ '(a b c d e) '(a b c d f) '(z b d c g) '(z y g c d))
16
24
  (a b c d e f z g y)))
@@ -0,0 +1,24 @@
1
+ (examples-for settings/fn
2
+ ("returns arg if it is a sym"
3
+ (settings/fn 'foobar)
4
+ foobar)
5
+
6
+ ("returns fn wrapper for arg if it is a string"
7
+ (settings/fn "hello")
8
+ (k "hello"))
9
+
10
+ ("returns fn wrapper for arg if it is a number"
11
+ (settings/fn 42)
12
+ (k 42))
13
+
14
+ ("returns fn wrapper for arg if it is nil"
15
+ (settings/fn nil)
16
+ (k nil))
17
+
18
+ ("wraps arg in a fn expression if it is a hash"
19
+ (settings/fn '{ a 1 b 2 })
20
+ (fn (_) { a 1 b 2 }))
21
+
22
+ ("wraps arg in a fn expression if it is a complex expression"
23
+ (settings/fn '(let foo this that (rfnwith (complex stuff) (%td.tricky#syntax))))
24
+ (fn (_) (let foo this that (rfnwith (complex stuff) ((percent-syntax || (dot-syntax td tricky#syntax))))))))
@@ -28,3 +28,11 @@
28
28
  (sort-by len
29
29
  '("short" "very long" "sport" "very song" "min" "max"))
30
30
  ("max" "min" "sport" "short" "very song" "very long")))
31
+
32
+ (examples-for safe-sort-by
33
+ ("sorts a list of hashes by a specified key"
34
+ (let hh (list { a 1 b 2 } { b 9 } { a 3 b 1 } { a nil b 8 })
35
+ (pp (safe-sort-by &a 99 hh)))
36
+ "({ a 1 b 2 } { a 3 b 1 }
37
+ { a nil b 8 }
38
+ { b 9 })"))
@@ -24,6 +24,15 @@
24
24
  (string-replace "and|or" "x" "a and b or c and d")
25
25
  "a x b x c x d"))
26
26
 
27
+ (examples-for string-truncate
28
+ ("truncates a string to the given length"
29
+ (string-truncate "a and b and c and d" 8)
30
+ "a and b ")
31
+
32
+ ("truncate to zero"
33
+ (string-truncate "a and b and long and complex" 0)
34
+ ""))
35
+
27
36
  (examples-for string-match
28
37
  ("no match returns nil"
29
38
  (string-match "this that another" "XXXX")
@@ -0,0 +1,12 @@
1
+ (examples-for zap
2
+ ("it adds a value to place"
3
+ (let a 10
4
+ (zap + a 2)
5
+ a)
6
+ 12)
7
+
8
+ ("it multiplies the value in a place"
9
+ (let a 10
10
+ (zap * a 2)
11
+ a)
12
+ 20))
@@ -7,11 +7,9 @@ module Nydp
7
7
 
8
8
  # TODO: write VM #apply_function so we have fewer calls to VM.new
9
9
  def self.apply_function ns, function_name, *args
10
- function = r2n(function_name.to_sym, ns).value
11
- args = r2n args, ns
12
10
  vm = VM.new(ns)
13
-
14
- function.invoke vm, args
11
+ function = Symbol.mk(function_name.to_sym, ns).value
12
+ function.invoke vm, r2n(args)
15
13
  vm.thread
16
14
  end
17
15
 
@@ -89,6 +87,7 @@ require "nydp/error"
89
87
  require "nydp/truth"
90
88
  require "nydp/version"
91
89
  require "nydp/helper"
90
+ require 'nydp/core_ext'
92
91
  require "nydp/symbol"
93
92
  require "nydp/symbol_lookup"
94
93
  require "nydp/pair"
@@ -1,10 +1,5 @@
1
1
  class Nydp::Builtin::CdrSet
2
2
  include Nydp::Builtin::Base, Singleton
3
3
 
4
- def builtin_invoke vm, args
5
- pair = args.car
6
- arg = args.cdr.car
7
- pair.cdr = arg
8
- vm.push_arg pair
9
- end
4
+ def builtin_invoke vm, args ; vm.push_arg(args.car.cdr = args.cdr.car) ; end
10
5
  end
@@ -25,7 +25,7 @@ class Nydp::Builtin::HandleError
25
25
  e = e.cause
26
26
  end
27
27
 
28
- handler.invoke_2 vm, vm.r2n(msgs)
28
+ handler.invoke_2 vm, r2n(msgs)
29
29
  end
30
30
 
31
31
  def to_s
@@ -10,49 +10,15 @@ end
10
10
  class Nydp::Builtin::HashGet
11
11
  include Nydp::Helper, Nydp::Builtin::Base, Singleton
12
12
  def builtin_invoke vm, args
13
- hsh = args.car
14
- key = args.cdr.car
15
- case hsh
16
- when Nydp::Hash
17
- vm.push_arg(hsh[key] || Nydp::NIL)
18
- when NilClass, Nydp::NIL
19
- vm.push_arg Nydp::NIL
20
- else
21
- v = hsh.respond_to?(:[]) ? hsh[n2r key] : ruby_call(hsh, key)
22
- vm.push_arg(r2n v, vm.ns)
23
- end
24
- end
25
-
26
- def ruby_call obj, method_name
27
- if obj.respond_to? :_nydp_safe_methods
28
- m = n2r(method_name).to_s.to_sym
29
- allowed = obj._nydp_safe_methods
30
-
31
- obj.send n2r(m) if allowed.include?(m)
32
- else
33
- raise "hash-get: Not a hash: #{obj.class.name}"
34
- end
13
+ vm.push_arg(args.car._nydp_get(args.cdr.car)._nydp_wrapper || Nydp::NIL)
35
14
  end
36
15
  end
37
16
 
38
17
  class Nydp::Builtin::HashSet
39
18
  include Nydp::Helper, Nydp::Builtin::Base, Singleton
40
19
  def builtin_invoke vm, args
41
- hash = args.car
42
- key = args.cdr.car
43
20
  value = args.cdr.cdr.car
44
- case hash
45
- when Nydp::Hash
46
- hash[key] = value
47
- when NilClass, Nydp::NIL
48
- nil
49
- else
50
- if hash.respond_to?(:[]=)
51
- hash[n2r key] = n2r value
52
- else
53
- raise "hash-set: Not a hash: #{hash.class.name}"
54
- end
55
- end
21
+ args.car._nydp_set(args.cdr.car, value)
56
22
  vm.push_arg value
57
23
  end
58
24
  end
@@ -60,14 +26,7 @@ end
60
26
  class Nydp::Builtin::HashKeys
61
27
  include Nydp::Helper, Nydp::Builtin::Base, Singleton
62
28
  def builtin_invoke vm, args
63
- hash = args.car
64
- if hash.is_a? Nydp::Hash
65
- vm.push_arg Nydp::Pair.from_list hash.keys
66
- elsif hash.respond_to?(:keys)
67
- vm.push_arg r2n(hash.keys.to_a.sort, vm.ns)
68
- else
69
- vm.push_arg Nydp::NIL
70
- end
29
+ vm.push_arg args.car._nydp_keys._nydp_wrapper
71
30
  end
72
31
  end
73
32
 
@@ -0,0 +1,41 @@
1
+ class Object
2
+ def _nydp_get a ; raise "_nydp_get : not gettable: #{a.inspect} on #{self.class.name}" ; end
3
+ def _nydp_set a, v ; raise "_nydp_get : not settable: #{a.inspect} on #{self.class.name}" ; end
4
+ def _nydp_keys ; [] ; end
5
+ def _nydp_wrapper ; self ; end
6
+ end
7
+
8
+ class NilClass
9
+ def _nydp_wrapper ; Nydp::NIL ; end
10
+ end
11
+
12
+ class FalseClass
13
+ def _nydp_wrapper ; Nydp::NIL ; end
14
+ end
15
+
16
+ class TrueClass
17
+ def _nydp_wrapper ; Nydp::T ; end
18
+ end
19
+
20
+ class ::Symbol
21
+ def _nydp_wrapper ; Nydp::FrozenSymbol.mk(self) ; end
22
+ end
23
+
24
+ class ::Date
25
+ def _nydp_wrapper ; Nydp::Date.new self ; end
26
+ end
27
+
28
+ class ::Array
29
+ def _nydp_wrapper ; Nydp::Pair.from_list map &:_nydp_wrapper ; end
30
+ end
31
+
32
+ class ::String
33
+ def _nydp_wrapper ; Nydp::StringAtom.new self ; end
34
+ end
35
+
36
+ class ::Hash
37
+ include Nydp::Helper
38
+ def _nydp_get a ; self[n2r a] ; end
39
+ def _nydp_set a, v ; self[n2r a] = n2r(v) ; end
40
+ def _nydp_keys ; keys ; end
41
+ end
@@ -16,23 +16,21 @@ module Nydp
16
16
  end
17
17
  end
18
18
 
19
- def initialize ruby_date
20
- @ruby_date = ruby_date
21
- end
19
+ def initialize ruby_date ; @ruby_date = ruby_date ; end
22
20
 
23
- def to_s ; ruby_date.to_s ; end
24
- def to_ruby ; ruby_date ; end
25
- def inspect ; ruby_date.inspect ; end
26
- def nydp_type ; :date ; end
27
- def + int ; r2n(ruby_date + int , nil) ; end
28
- def > other ; is_date?(other) && ruby_date > other.ruby_date ; end
29
- def < other ; is_date?(other) && ruby_date < other.ruby_date ; end
30
- def == other ; is_date?(other) && ruby_date == other.ruby_date ; end
31
- def <=> other ; is_date?(other) && ruby_date <=> other.ruby_date ; end
32
- def eql? d ; self == d ; end
33
- def hash ; ruby_date.hash ; end
34
- def is_date? other ; other.is_a? Nydp::Date ; end
35
- def - other ; r2n(ruby_date - (is_date?(other) ? other.ruby_date : other), nil) ; end
21
+ def to_s ; ruby_date.to_s ; end
22
+ def to_ruby ; ruby_date ; end
23
+ def inspect ; ruby_date.inspect ; end
24
+ def nydp_type ; :date ; end
25
+ def + int ; r2n(ruby_date + int) ; end
26
+ def > other ; is_date?(other) && ruby_date > other.ruby_date ; end
27
+ def < other ; is_date?(other) && ruby_date < other.ruby_date ; end
28
+ def == other ; is_date?(other) && ruby_date == other.ruby_date ; end
29
+ def <=> other ; is_date?(other) && ruby_date <=> other.ruby_date ; end
30
+ def eql? d ; self == d ; end
31
+ def hash ; ruby_date.hash ; end
32
+ def is_date? other ; other.is_a? Nydp::Date ; end
33
+ def - other ; r2n(ruby_date - (is_date?(other) ? other.ruby_date : other)) ; end
36
34
 
37
35
  @@pass_through = %i{ monday? tuesday? wednesday? thursday? friday? saturday? sunday? }
38
36
  @@keys = Set.new %i{
@@ -70,17 +68,17 @@ module Nydp
70
68
  class_eval "def #{n} * ; ruby_date.#{n} ; end"
71
69
  end
72
70
 
73
- def keys ; @@keys ; end
74
- def dispatch key, y, m, d, w ; self.send(key, y, m, d, w) if keys.include?(key) ; end
71
+ def _nydp_keys ; @@keys.to_a ; end
72
+ def dispatch key, y, m, d, w ; self.send(key, y, m, d, w) if _nydp_keys.include?(key) ; end
75
73
 
76
- def [] key
74
+ def _nydp_get key
77
75
  key = key.to_s.gsub(/-/, '_').to_sym
78
76
  y = ruby_date.year
79
77
  m = ruby_date.month
80
78
  d = ruby_date.day
81
79
  w = ruby_date.wday
82
80
 
83
- r2n(dispatch(key, y, m, d, w), nil)
81
+ r2n(dispatch(key, y, m, d, w))
84
82
  end
85
83
  end
86
84
  end