subtype 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/subtype.rb +92 -86
  2. metadata +3 -3
data/lib/subtype.rb CHANGED
@@ -18,8 +18,8 @@
18
18
  #++
19
19
 
20
20
  class ::Subtle::Sublet
21
- def use(str)
22
- self.instance_eval(str) if str.is_a?(String)
21
+ def use (klass)
22
+ klass.included(self)
23
23
  end
24
24
  end
25
25
 
@@ -61,95 +61,101 @@ module SubType
61
61
  end
62
62
  end
63
63
 
64
- Rotate = <<-EOF
65
- alias __set_data__ data=
66
- alias __get_data__ data
67
- alias __on__ on
68
-
69
- self.rotation = SubType::RotationType.new('', self.config[:length])
70
- self.thread = Thread.start(self) {|s|
71
- loop {
72
- s.__set_data__(s.data.pre + s.data.next + s.data.post)
73
- sleep 0.1
74
- }
75
- }
76
-
77
- def data=(str)
78
- self.rotation.update(str)
79
- str
80
- end
81
-
82
- def data
83
- self.rotation
84
- end
85
-
86
- def on(meth, &blk)
87
- case meth
88
- when :unload
89
- __on__(meth) {|s|
90
- blk.call(s)
91
- s.thread.kill
64
+ module Rotate
65
+ def self.included (klass)
66
+ klass.instance_eval {
67
+ alias __set_data__ data=
68
+ alias __get_data__ data
69
+ alias __on__ on
70
+
71
+ self.rotation = SubType::RotationType.new('', self.config[:length])
72
+ self.thread = Thread.start(self) {|s|
73
+ loop {
74
+ s.__set_data__(s.data.pre + s.data.next + s.data.post)
75
+ sleep 0.1
76
+ }
77
+ }
78
+
79
+ def data=(str)
80
+ self.rotation.update(str)
81
+ str
82
+ end
83
+
84
+ def data
85
+ self.rotation
86
+ end
87
+
88
+ def on(meth, &blk)
89
+ case meth
90
+ when :unload
91
+ __on__(meth) {|s|
92
+ blk.call(s)
93
+ s.thread.kill
94
+ }
95
+ else
96
+ __on__(meth, &blk)
97
+ end
98
+ end
92
99
  }
93
- else
94
- __on__(meth, &blk)
95
100
  end
96
101
  end
97
- EOF
98
-
99
- Expand = <<-EOF
100
- helper do
101
- def __refresh
102
- begin
103
- self.data = self.respond_to?(:refresh) ? self.refresh : ''
104
- rescue
105
- self.data = 'ERROR'
106
- end
107
- end
108
- end
109
-
110
- on :run do |s|
111
- s.type = s.type ? s.type : :short
112
- s.__refresh
113
- end
114
102
 
115
- on :mouse_over do |s|
116
- s.type = :long
117
- s.__refresh
118
- end
119
-
120
- on :mouse_out do |s|
121
- s.type = :short
122
- s.__refresh
123
- end
124
-
125
- alias __on__ on
126
-
127
- def on(meth, &blk)
128
- case meth
129
- when :run
130
- __on__(meth) {|s|
131
- s.type = s.type ? s.type : :short
132
- blk.call(s)
133
- s.__refresh
134
- }
135
- when :mouse_over
136
- __on__(meth) {|s|
137
- blk.call(s)
138
- s.type = :long
139
- s.__refresh
140
- }
141
- when :mouse_out
142
- __on__(meth) {|s|
143
- blk.call(s)
144
- s.type = :short
145
- s.__refresh
146
- }
147
- else
148
- __on__(meth) {|*args|
149
- blk.call(*args)
150
- args.last.__refresh
103
+ module Expand
104
+ def self.included (klass)
105
+ klass.instance_eval {
106
+ helper do
107
+ def __refresh
108
+ self.data = self.respond_to?(:refresh) ? self.refresh : ''
109
+ rescue
110
+ self.data = 'ERROR'
111
+ end
112
+ end
113
+
114
+ on :run do |s|
115
+ s.type = s.type ? s.type : :short
116
+ s.__refresh
117
+ end
118
+
119
+ on :mouse_over do |s|
120
+ s.type = :long
121
+ s.__refresh
122
+ end
123
+
124
+ on :mouse_out do |s|
125
+ s.type = :short
126
+ s.__refresh
127
+ end
128
+
129
+ alias __on__ on
130
+
131
+ def on(meth, &blk)
132
+ case meth
133
+ when :run
134
+ __on__(meth) {|s|
135
+ s.type = s.type ? s.type : :short
136
+ blk.call(s)
137
+ s.__refresh
138
+ }
139
+ when :mouse_over
140
+ __on__(meth) {|s|
141
+ blk.call(s)
142
+ s.type = :long
143
+ s.__refresh
144
+ }
145
+ when :mouse_out
146
+ __on__(meth) {|s|
147
+ blk.call(s)
148
+ s.type = :short
149
+ s.__refresh
150
+ }
151
+ else
152
+ __on__(meth) {|*args|
153
+ blk.call(*args)
154
+ args.last.__refresh
155
+ }
156
+ end
157
+ end
151
158
  }
152
159
  end
153
160
  end
154
- EOF
155
161
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - shura
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-04-20 00:00:00 +02:00
17
+ date: 2011-06-23 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies: []
20
20