yield_source 0.0.11 → 0.0.13
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 +4 -4
- data/lib/yield_source.rb +104 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f50b4980af2d2a50ebd521f773c4dceb9dfbd171b934ab3a06b2e022fada0557
|
4
|
+
data.tar.gz: c2e88bf61b793da32b37408c021c60429598bd8fbfb0cb4200fcfb4a7b3e9d3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cb36bb68149865f9dd4c62d2d295156f27d837197ab42326f952cd05bed0ed47b231019e5a1970388118a706b52b7639cd82308537a7247211cc6af2f5f786e
|
7
|
+
data.tar.gz: 646a5a067a3038e3bd1582aac029f9a22f4da76394296d358d071f6b02f0919399153fc6761aa9d45f1cce638b8d5e78f4cf20fc8ac0c792cca05ed16b058424
|
data/lib/yield_source.rb
CHANGED
@@ -1,24 +1,88 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
|
1
3
|
class Object
|
2
|
-
|
4
|
+
|
3
5
|
def what_the()
|
4
|
-
|
5
|
-
|
6
|
-
|
6
|
+
system 'clear'
|
7
|
+
if !File.file?("./zmem.txt")
|
8
|
+
if !block_given?
|
9
|
+
puts
|
10
|
+
puts("Come on! Give me a block!".yellow)
|
11
|
+
print("(Remember what you do with a ".blue)
|
12
|
+
print(".each ".red)
|
13
|
+
puts("loop..)".blue)
|
14
|
+
puts
|
15
|
+
File.open("./zmem.txt", 'w') { |file| file.write("mem=1") }
|
16
|
+
else
|
17
|
+
puts("\nHow did this work?!".red)
|
18
|
+
puts("Where is this coming from?\n".light_blue)
|
19
|
+
yield("Found me!..\nYou can move on\n".yellow)
|
20
|
+
end
|
21
|
+
else
|
22
|
+
if !block_given?
|
23
|
+
content = File.read("./zmem.txt")
|
24
|
+
content_arr = content.split('=')
|
25
|
+
times = content_arr[1]
|
26
|
+
if times == "1"
|
27
|
+
puts
|
28
|
+
puts("Really?! Still no block?! If you get it wrong again, I'll give you a hint..".yellow)
|
29
|
+
puts
|
30
|
+
File.open("./zmem.txt", 'w') { |file| file.write("mem=2") }
|
31
|
+
elsif times == "2"
|
32
|
+
puts
|
33
|
+
puts("Hmm, ok then.".light_blue)
|
34
|
+
puts("This is a method that takes a block.".yellow)
|
35
|
+
print("Blocks start with a ".light_blue)
|
36
|
+
print("do".red)
|
37
|
+
print(", and close with an ".light_blue)
|
38
|
+
print("end".red)
|
39
|
+
puts(".".light_blue)
|
40
|
+
puts
|
41
|
+
File.open("./zmem.txt", 'w') { |file| file.write("mem=3") }
|
42
|
+
elsif times == "3"
|
43
|
+
puts("\nAlso, blocks sometimes take a block argument, which will help you out during this challenge.\n".yellow)
|
44
|
+
File.open("./zmem.txt", 'w') { |file| file.write("mem=4") }
|
45
|
+
else
|
46
|
+
puts
|
47
|
+
puts("If you are still getting this wrong, you need to slack someone!".red)
|
48
|
+
puts
|
49
|
+
end
|
50
|
+
else
|
51
|
+
puts("\nHow did this work?!".red)
|
52
|
+
puts("Where is this coming from?\n".light_blue)
|
53
|
+
yield("Found me!..\nYou can move on!\n".yellow)
|
54
|
+
end
|
55
|
+
end
|
7
56
|
end
|
8
57
|
|
9
58
|
end
|
10
59
|
|
11
60
|
class YieldSource
|
12
61
|
|
13
|
-
def what_is_it
|
14
|
-
|
62
|
+
def what_is_it()
|
63
|
+
# system 'clear'
|
64
|
+
if File.file?("./zmem.txt")
|
65
|
+
File.delete("./zmem.txt")
|
66
|
+
end
|
67
|
+
if !block_given?
|
68
|
+
system 'clear'
|
69
|
+
puts("\nNot again!!".yellow)
|
70
|
+
puts("Gimme a BLOCK!\n".red)
|
71
|
+
else
|
72
|
+
yield("\nWell done!\n\n".yellow + "This one just reinforces the last one.\nMove on to the next problem.\n".red)
|
73
|
+
end
|
15
74
|
end
|
16
75
|
|
17
76
|
def yielder(num1, num2)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
77
|
+
if !block_given?
|
78
|
+
system 'clear'
|
79
|
+
puts("\nGrrrrrrrrrrrrrrrr!\n".magenta)
|
80
|
+
else
|
81
|
+
puts("\nBefore the yield..\n".light_blue)
|
82
|
+
result = num1 ** num2
|
83
|
+
yield(result)
|
84
|
+
puts("\n..after the yield.\n".light_blue)
|
85
|
+
end
|
22
86
|
end
|
23
87
|
|
24
88
|
def how_many(str)
|
@@ -29,7 +93,7 @@ class YieldSource
|
|
29
93
|
e_count += 1
|
30
94
|
end
|
31
95
|
end
|
32
|
-
yield(e_count)
|
96
|
+
yield("\n\t#{e_count}\n".green)
|
33
97
|
end
|
34
98
|
|
35
99
|
def what_is_it_this_time(str)
|
@@ -39,7 +103,7 @@ class YieldSource
|
|
39
103
|
num_arr << sub_str.length
|
40
104
|
end
|
41
105
|
num_arr.each do |num|
|
42
|
-
yield(num)
|
106
|
+
yield("\t#{num}".red)
|
43
107
|
end
|
44
108
|
end
|
45
109
|
|
@@ -71,4 +135,32 @@ class YieldSource
|
|
71
135
|
yield(output_hash)
|
72
136
|
end
|
73
137
|
|
138
|
+
# More examples with the block returning something
|
139
|
+
# Adjust to whether they have given a block.
|
74
140
|
end
|
141
|
+
|
142
|
+
# what_the() do |x|
|
143
|
+
# puts x
|
144
|
+
# end
|
145
|
+
|
146
|
+
yield_obj = YieldSource.new()
|
147
|
+
|
148
|
+
# yield_obj.what_is_it() do |ahh|
|
149
|
+
# puts ahh
|
150
|
+
# end
|
151
|
+
|
152
|
+
# yield_obj.yielder(2, 7) do |b|
|
153
|
+
# puts b
|
154
|
+
# end
|
155
|
+
|
156
|
+
# yield_obj.how_many("jjjpppp") do |j|
|
157
|
+
# puts j
|
158
|
+
# end
|
159
|
+
|
160
|
+
# yield_obj.what_is_it_this_time("kjsldddsssldlswwwwwww") do |w, k|
|
161
|
+
# puts w
|
162
|
+
# end
|
163
|
+
|
164
|
+
# yield_obj.argsss("What is this?") do |o,j,m|
|
165
|
+
# puts o, j, m
|
166
|
+
# end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yield_source
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- batteries76
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Gives access to some methods that have a yield underpinning them
|
14
14
|
email: []
|