random_text 0.0.1 → 0.0.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.
- data/Rakefile +1 -1
- data/lib/random_text.rb +14 -0
- metadata +2 -2
data/Rakefile
CHANGED
data/lib/random_text.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'activesupport'
|
3
3
|
|
4
|
+
$KCODE = "u"
|
5
|
+
|
4
6
|
class RandomText
|
5
7
|
class Randomized
|
6
8
|
def initialize(data)
|
@@ -11,6 +13,10 @@ class RandomText
|
|
11
13
|
@list << s
|
12
14
|
s
|
13
15
|
end
|
16
|
+
def unique(n)
|
17
|
+
raise "Dictionary has only #{@list.length} elements (you asked for n)" if n > @list.length
|
18
|
+
@list.sort{ rand - 0.5 }.slice(0, n)
|
19
|
+
end
|
14
20
|
end
|
15
21
|
|
16
22
|
def initialize(*args)
|
@@ -22,6 +28,14 @@ class RandomText
|
|
22
28
|
def word
|
23
29
|
@words.get
|
24
30
|
end
|
31
|
+
|
32
|
+
def words(n)
|
33
|
+
Array.new(n){ word }.join(' ').capitalize
|
34
|
+
end
|
35
|
+
|
36
|
+
def unique_words(n)
|
37
|
+
@words.unique(n)
|
38
|
+
end
|
25
39
|
|
26
40
|
def sentence
|
27
41
|
@sentences.get
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: random_text
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- toy
|
@@ -9,7 +9,7 @@ autorequire: random_text
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-09-02 00:00:00 +04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|