curse 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -2
- data/lib/curse.rb +56 -4
- data/lib/curse/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Curse
|
2
2
|
|
3
|
-
|
3
|
+
make ruby objects curse each other, just curse, or become cursed.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,7 +18,13 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
require 'curse'
|
22
|
+
|
23
|
+
6.curse 7
|
24
|
+
curse
|
25
|
+
|
26
|
+
victim = MyClass.new
|
27
|
+
victim.curse! #and watch the fireworks
|
22
28
|
|
23
29
|
## Contributing
|
24
30
|
|
data/lib/curse.rb
CHANGED
@@ -1,15 +1,67 @@
|
|
1
1
|
require "curse/version"
|
2
2
|
|
3
3
|
module Curse
|
4
|
+
@@curses = {}
|
4
5
|
|
5
|
-
|
6
|
+
def self.register(handle, klass)
|
7
|
+
@@curses[handle] = klass.new
|
8
|
+
end
|
6
9
|
|
7
|
-
|
10
|
+
def self.language=(handle)
|
11
|
+
@@active = @@curses[handle]
|
12
|
+
end
|
8
13
|
|
9
|
-
def
|
14
|
+
def curses
|
10
15
|
rand(4).times.map do
|
11
|
-
|
16
|
+
@@active.curse
|
12
17
|
end.join(' ') + '!'
|
18
|
+
end
|
19
|
+
|
20
|
+
def adverbs
|
21
|
+
rand(4).times.map { @@active.adverb }
|
22
|
+
end
|
23
|
+
|
24
|
+
class Comic
|
25
|
+
|
26
|
+
def curse
|
27
|
+
(3 + rand(4)).times.map { ['%','#','@', '*', '&'].sample }.join
|
28
|
+
end
|
29
|
+
|
30
|
+
def adverb
|
31
|
+
"#{curse}ing"
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
Curse.register(:comic, Curse::Comic)
|
41
|
+
Curse.language = :comic
|
42
|
+
|
43
|
+
|
44
|
+
class Object
|
45
|
+
include Curse
|
46
|
+
|
47
|
+
def curse(other = nil)
|
48
|
+
if other
|
49
|
+
"#{self}: #{ Kernel.adverbs.join(' ') } #{other}"
|
50
|
+
else
|
51
|
+
"#{self}: #{Kernel.curses}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def curse!
|
56
|
+
|
57
|
+
(methods - Object.methods).sample(4).each do |method|
|
58
|
+
|
59
|
+
define_singleton_method method do |*args|
|
60
|
+
puts self.curse
|
61
|
+
rand(20)
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
13
65
|
|
14
66
|
end
|
15
67
|
|
data/lib/curse/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: curse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-31 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: make ruby curse
|
15
15
|
email:
|