letov 0.0.1
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.
- checksums.yaml +7 -0
- data/lib/letov.rb +26 -0
- data/lib/output.json +10564 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 22f6b56ce56eb390cc45173bf917309eaa26c382
|
4
|
+
data.tar.gz: 68caa1a675f4f8aaabe1e43f059fe4376a43ea39
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 84ecc44e50060c3e1a589bfe84cba22e62c4c2397d1be85f77e89ef719831189ea417536032c69a9a2c2d34c178e8be266d1911756b82b9a87ed55c391605f97
|
7
|
+
data.tar.gz: f317fffbeb1aafcacce086dc1470729a9bb894b7e3bdc8942e46866e4fcd40634f295366078518f3df3161c2f1834da94e85a5133acb87a8eab12428cf523783
|
data/lib/letov.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
class Letov
|
4
|
+
@@lyrics = nil
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@@lyrics = JSON.parse(open_file())
|
8
|
+
end
|
9
|
+
|
10
|
+
def say
|
11
|
+
begin
|
12
|
+
@song = rand(0..@@lyrics.size)
|
13
|
+
@string = rand(0..@@lyrics[@song]['lyrics'].size)
|
14
|
+
@choose = @@lyrics[@song]['lyrics'][@string]
|
15
|
+
return @choose == nil ? self.say() : @choose
|
16
|
+
rescue NoMethodError
|
17
|
+
self.say()
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def open_file
|
23
|
+
return File.read(File.join( File.dirname(__FILE__), 'output.json' ))
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|