LoremKnight 1.6.9 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tiger.rb +78 -15
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a0abb5ac0cb74b8bb3d7aacb34a26c6f7a9c380
|
4
|
+
data.tar.gz: 2c0efbe95351b6be8ac1a6e62b6ba630c5f836c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8df7a19ee8a091c62ebee95aa6bb929797a3fe32287266cb78057efefded8cd3bfabdafc68db2eb6340364094d1598291567241b7e1aef59653bad026740a3b
|
7
|
+
data.tar.gz: fb715f81929e2a3ee3926668d51af3765133fa5a2bb248179e2f0c753744f948dc60102eb408c9aee12edee35252138fd1a06abb5baf7fd4ea4d95562732dde5
|
data/lib/tiger.rb
CHANGED
@@ -2,29 +2,92 @@ $source_location = File.dirname(__FILE__)
|
|
2
2
|
require 'open-uri'
|
3
3
|
|
4
4
|
class Tiger
|
5
|
-
def self.generate(sentence,words)
|
6
|
-
@sentence = ""
|
7
|
-
@content = ""
|
8
5
|
|
9
|
-
|
6
|
+
@content = ""
|
7
|
+
@paragraphStandartSize = 70;
|
8
|
+
@sentenceStandartSize = 7;
|
10
9
|
|
11
|
-
|
12
|
-
|
10
|
+
@doHTML = false
|
11
|
+
@doPresentence = false
|
12
|
+
|
13
|
+
contentFromhttp = ""
|
14
|
+
source = open('https://raw.githubusercontent.com/gugakatsi/LoremKnight/master/lib/words.txt')
|
15
|
+
|
16
|
+
source.each do |char|
|
17
|
+
contentFromhttp += char
|
18
|
+
end
|
19
|
+
|
20
|
+
@content = contentFromhttp.split(" ")
|
21
|
+
|
22
|
+
|
23
|
+
def initialize(doHTML,doPresentence)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.getSentence(sentenceN)
|
27
|
+
lorem(sentenceN,@sentenceStandartSize,'')
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.getParagraph(paragraphN)
|
31
|
+
lorem(paragraphN,paragraphStandartSize,'')
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.getWords(wordN)
|
35
|
+
@words = ""
|
36
|
+
wordN.to_i.times do
|
37
|
+
@words += @content[rand(@content.size)]+" "
|
13
38
|
end
|
39
|
+
return @words
|
40
|
+
end
|
14
41
|
|
15
|
-
|
42
|
+
def self.setSentenceStandartSize(size)
|
43
|
+
if size.to_i > 0
|
44
|
+
@sentenceStandartSize = size.to_i
|
45
|
+
else
|
46
|
+
puts "Value can not be less or equal to 0"
|
47
|
+
end
|
48
|
+
end
|
16
49
|
|
17
|
-
|
18
|
-
|
50
|
+
def self.setParagraphStadartSize(size)
|
51
|
+
if size.to_i > 0
|
52
|
+
@paragraphStandartSize = size.to_i
|
53
|
+
else
|
54
|
+
puts "Value can not be less or equal to 0"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.setWordMaximumLength(length)
|
59
|
+
if length.to_i > 0
|
60
|
+
|
61
|
+
else
|
19
62
|
|
20
|
-
sentenceTimes.times do
|
21
|
-
wordTimes.times do
|
22
|
-
@sentence += @words[rand(@words.size-1)]+" "
|
23
|
-
end
|
24
|
-
@sentence += " , "
|
25
63
|
end
|
64
|
+
end
|
26
65
|
|
27
|
-
|
66
|
+
end
|
67
|
+
|
68
|
+
def lorem(header,body,startWith = '')
|
28
69
|
|
70
|
+
@sentence = ""
|
71
|
+
|
72
|
+
header.times do
|
73
|
+
body.times do
|
74
|
+
@sentence += @content[rand(@content.size)]+" "
|
75
|
+
end
|
76
|
+
@sentence += startWith == '' ? " /n " : " /n "+@preSentence
|
29
77
|
end
|
78
|
+
return @sentence
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
def loremHTML(header,body,startWith = '')
|
83
|
+
@sentenceHTML = ""
|
84
|
+
|
85
|
+
header.times do
|
86
|
+
body.times do
|
87
|
+
@sentenceHTML += @content[rand(@content.size)]+" "
|
88
|
+
end
|
89
|
+
@sentenceHTML += startWith == '' ? "</p> <br> <br> " : "</p> <br> <br> "+@preSentence
|
90
|
+
end
|
91
|
+
return @sentence
|
92
|
+
|
30
93
|
end
|