• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Ruby GTK3移行後のメインリポジトリ


Commit MetaInfo

Revisiond9ff101b59ad6ff16370e2f68b18cd31cb6303c9 (tree)
Time2014-04-10 23:02:58
AuthorShyouzou Sugitani <shy@user...>
CommiterShyouzou Sugitani

Log Message

add metamagic.rb

Change Summary

Incremental Difference

--- /dev/null
+++ b/lib/ninix/metamagic.rb
@@ -0,0 +1,184 @@
1+# -*- coding: utf-8 -*-
2+#
3+# metamagic.py - unknown unknowns
4+# Copyright (C) 2011-2014 by Shyouzou Sugitani <shy@users.sourceforge.jp>
5+#
6+# This program is free software; you can redistribute it and/or modify it
7+# under the terms of the GNU General Public License (version 2) as
8+# published by the Free Software Foundation. It is distributed in the
9+# hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
10+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11+# PURPOSE. See the GNU General Public License for more details.
12+#
13+
14+module MetaMagic
15+
16+ class Meme
17+
18+ def initialize(key)
19+ @key = key
20+ @baseinfo = nil
21+ @menuitem = nil
22+ end
23+
24+ def create_menuitem(data)
25+ return nil
26+ end
27+
28+ def delete_by_myself
29+ end
30+
31+ def key
32+ return @key
33+ end
34+
35+ def key=(data) # read only
36+ end
37+
38+ def baseinfo
39+ return @baseinfo
40+ end
41+
42+ def baseinfo=(data)
43+ @baseinfo = data
44+ @menuitem = create_menuitem(data)
45+ if menuitem == nil
46+ delete_by_myself()
47+ return
48+ end
49+ @menuitem = menuitem
50+ end
51+
52+ def menuitem
53+ return @menuitem
54+ end
55+
56+ def menuitem=(data) # read only
57+ end
58+ end
59+
60+
61+ class Holon
62+
63+ def initialize(key)
64+ @key = key
65+ @baseinfo = nil
66+ @menuitem = nil
67+ @instance = nil
68+ end
69+
70+ def create_menuitem(data)
71+ return nil
72+ end
73+
74+ def delete_by_myself
75+ end
76+
77+ def create_instance(data)
78+ return nil
79+ end
80+
81+ def key=(data) # read only
82+ end
83+
84+ def key
85+ return @key
86+ end
87+
88+ def baseinfo # forbidden
89+ return nil
90+ end
91+
92+ def baseinfo=(data)
93+ @baseinfo = data
94+ if @instance == nil
95+ @instance = create_instance(data)
96+ end
97+ if @instance == nil
98+ delete_by_myself()
99+ return
100+ else
101+ @instance.new(data) # reset
102+ menuitem = create_menuitem(data)
103+ if menuitem == nil
104+ delete_by_myself()
105+ return
106+ end
107+ @menuitem = menuitem
108+ end
109+ end
110+
111+ def menuitem
112+ return @menuitem
113+ end
114+
115+ def menuitem=(data) # read only
116+ end
117+
118+ def instance
119+ return @instance
120+ end
121+
122+ def instance=(data) # read only
123+ end
124+ end
125+
126+ class TEST_Meme < Meme
127+
128+ def create_menuitem(data)
129+ return data => 'menu'
130+ end
131+ end
132+
133+ class TEST_Holon < Holon
134+
135+ def create_menuitem(data)
136+ return data => 'menu'
137+ end
138+
139+ def create_instance(data)
140+ return Hash
141+ end
142+ end
143+
144+ class TEST
145+
146+ def initialize
147+ meme = TEST_Meme.new('meta')
148+ meme.baseinfo = 'base'
149+ meme.key = ''
150+ meme.menuitem = ''
151+ print("Meme: \n")
152+ print(" KEY: ")
153+ print(meme.key)
154+ print("\n")
155+ print(" BASE INFO: ")
156+ print(meme.baseinfo)
157+ print("\n")
158+ print(" MENU ITEM: ")
159+ print(meme.menuitem)
160+ print("\n")
161+
162+ holon = TEST_Holon.new('magic')
163+ holon.baseinfo = 'base'
164+ holon.key = ''
165+ holon.menuitem = ''
166+ holon.instance = ''
167+ print("HOLON: \n")
168+ print(" KEY: ")
169+ print(holon.key)
170+ print("\n")
171+ print(" BASE INFO: ")
172+ print(holon.baseinfo)
173+ print("\n")
174+ print(" MENU ITEM: ")
175+ print(holon.menuitem)
176+ print("\n")
177+ print(" INSTANCE: ")
178+ print(holon.instance)
179+ print("\n")
180+ end
181+ end
182+end
183+
184+MetaMagic::TEST.new