This repository was archived by the owner on Sep 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -109,6 +109,8 @@ LIBS.RAPHAEL = RAPHAEL_LIB
109109-- \____/\__,_/____/\__/\____/_/ /_/ /_/ \____/_/\__,_/____/____/\___/____/
110110--
111111
112+ @include(src/Classes/Expander Class.lua)
113+
112114@include(src/Classes/Point Class.lua)
113115
114116@include(src/Classes/Area Class.lua)
Original file line number Diff line number Diff line change 1+ Expander = { __class = ' Expander' }
2+ ExpanderMT = { __index = Expander }
3+
4+ function Expander :new (filter , expander )
5+ local newObj = {
6+ filter = filter ,
7+ expander = expander
8+ }
9+
10+ setmetatable (newObj , ExpanderMT )
11+ return newObj
12+ end
13+
14+ function Expander :makeFilter (objType )
15+ return function (v )
16+ return type (v ) == objType
17+ end
18+ end
19+
20+ function Expander :makeExpander (...)
21+ local props = {... }
22+ return function (v )
23+ local vals = {}
24+ for _ , vv in ipairs (props ) do
25+ table.insert (vals , getvalue (v [vv ]))
26+ end
27+
28+ return table.unpack (vals )
29+ end
30+ end
31+
32+ function Expander :expand (...)
33+ local args = {... }
34+
35+ for k , v in ipairs (args ) do
36+ if self .filter (v ) then
37+ args [k ] = {self .expander (v )}
38+ end
39+ end
40+
41+ table .flatten (args )
42+ return table.unpack ()
43+ end
You can’t perform that action at this time.
0 commit comments