quote_machine 0.2.4 → 0.2.5
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/Gemfile.lock +1 -1
- data/complete_verse.txt +23 -4
- data/lib/quote_machine/version.rb +1 -1
- data/lib/quote_machine.rb +85 -33
- 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: bc259e1dfc6d0a968ad486d2856eb46291dd7db56421a1f1c81301fcbcbd2ac9
|
4
|
+
data.tar.gz: 7529f3e7e251dd63fefd3a6fa4b1cb4b7e25add3b570c034e968239e8c48fc5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e1e5a50cef5437b2a3a8a1c97ab749d444b8ec3bd6497a61a9728f48e892d00b545ef5851d179783166e1900e88a5b7a2bcb5eb250afc1122acbc609d562f14
|
7
|
+
data.tar.gz: 02cbc2fa9b204da4f480ce64e330e7b205b79214969ca80dd92432b5b3f95d76dd1ab02f459e179dd99390f3534648e162051008e44a9d9e923d86dab7e0eb87
|
data/Gemfile.lock
CHANGED
data/complete_verse.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
0
|
2
2
|
|
3
3
|
I believe in you my soul, the other I am must not abase itself to you,
|
4
4
|
And you must not be abased to the other.
|
@@ -21,7 +21,7 @@ And limitless are leaves stiff or drooping in the fields,
|
|
21
21
|
And brown ants in the little wells beneath them,
|
22
22
|
And mossy scabs of the worm fence, heap’d stones, elder, mullein and poke-weed.
|
23
23
|
|
24
|
-
|
24
|
+
1
|
25
25
|
|
26
26
|
A child said WHAT IS THE GRASS? fetching it to me with full hands;
|
27
27
|
How could I answer the child? I do not know what it is any more than he.
|
@@ -69,7 +69,7 @@ And ceas'd the moment life appear'd.
|
|
69
69
|
All goes onward and outward, nothing collapses,
|
70
70
|
And to die is different from what any one supposed, and luckier.
|
71
71
|
|
72
|
-
|
72
|
+
2
|
73
73
|
|
74
74
|
Has any one supposed it lucky to be born?
|
75
75
|
I hasten to inform him or her it is just as lucky to die, and I know it.
|
@@ -91,4 +91,23 @@ For me children and the begetters of children.
|
|
91
91
|
|
92
92
|
Undrape! you are not guilty to me, nor stale nor discarded,
|
93
93
|
I see through the broadcloth and gingham whether or no,
|
94
|
-
And am around, tenacious, acquisitive, tireless, and cannot be shaken away.
|
94
|
+
And am around, tenacious, acquisitive, tireless, and cannot be shaken away.
|
95
|
+
|
96
|
+
3
|
97
|
+
|
98
|
+
A stanza with only one section.
|
99
|
+
|
100
|
+
4
|
101
|
+
|
102
|
+
A stanza with two sections.
|
103
|
+
|
104
|
+
The second section.
|
105
|
+
|
106
|
+
5
|
107
|
+
|
108
|
+
A stanz with three sections.
|
109
|
+
|
110
|
+
Section two of three.
|
111
|
+
|
112
|
+
Section three of three.
|
113
|
+
|
data/lib/quote_machine.rb
CHANGED
@@ -11,6 +11,8 @@ def declare_instance_variables
|
|
11
11
|
@stanza_pick = 0
|
12
12
|
@stanza_current = 0
|
13
13
|
@section_current = 0
|
14
|
+
@section_previous = "na"
|
15
|
+
@section_next = "na"
|
14
16
|
end
|
15
17
|
|
16
18
|
def set_stanza_and_section
|
@@ -19,6 +21,20 @@ def set_stanza_and_section
|
|
19
21
|
@section_current = pick_section(stanza)
|
20
22
|
end
|
21
23
|
|
24
|
+
def set_next_section
|
25
|
+
if @section_current < (@poem[@stanza_current].length-1)
|
26
|
+
@section_next = @section_current + 1
|
27
|
+
end
|
28
|
+
@section_next
|
29
|
+
end
|
30
|
+
|
31
|
+
def set_previous_section
|
32
|
+
if @section_current > 1
|
33
|
+
@section_previous = @section_current - 1
|
34
|
+
end
|
35
|
+
@section_previous
|
36
|
+
end
|
37
|
+
|
22
38
|
|
23
39
|
def read_poem(file_name)
|
24
40
|
text = File.read(file_name)
|
@@ -147,40 +163,76 @@ def main_program
|
|
147
163
|
# display_interface
|
148
164
|
end
|
149
165
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
#
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
#
|
160
|
-
|
161
|
-
#
|
162
|
-
|
163
|
-
#
|
164
|
-
|
165
|
-
|
166
|
-
#
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
# elsif option == 5
|
173
|
-
# clear_screen
|
174
|
-
# show_entire_verse
|
175
|
-
# elsif option == 6
|
176
|
-
# clear_screen
|
177
|
-
# show_entire_poem
|
178
|
-
# else
|
179
|
-
# puts "end"
|
180
|
-
# end
|
181
|
-
# end
|
182
|
-
# end
|
166
|
+
def build_display
|
167
|
+
result_text = ""
|
168
|
+
@phrase.each do |section|
|
169
|
+
|
170
|
+
# Build For a stanza with only one section
|
171
|
+
if @poem[@stanza_current].length == 2
|
172
|
+
result_text = show_current_section
|
173
|
+
end
|
174
|
+
|
175
|
+
# Builds For a stanza with only two sections and only one phrase
|
176
|
+
if @poem[@stanza_current].length == 3
|
177
|
+
# if there is only one phrase
|
178
|
+
if @phrase.length == 1
|
179
|
+
#the phrase if the first phrase of the stanza
|
180
|
+
if @phrase[0] == 1
|
181
|
+
result_text = show_current_section + "<div class='plus-button'>+</div>"
|
182
|
+
#the phrase is the second phrase of the stanza
|
183
|
+
elsif @phrase[0] == 2
|
184
|
+
result_text = "<div class='plus-button'>+</div>" + show_current_section
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
183
188
|
|
189
|
+
# Builds for a Stanza with more than two sections and only one phrase
|
190
|
+
if @poem[@stanza_current].length > 3
|
191
|
+
if @phrase.length == 1
|
192
|
+
if @phrase[0] == 1
|
193
|
+
result_text = show_current_section + "<div class='plus-button'>+</div>"
|
194
|
+
elsif (@phrase[0] >= 2) && @phrase[0] < @poem[@stanza_current].length - 1
|
195
|
+
result_text = "<div class='plus-button'>+</div>" + show_current_section + "<div class='plus-button'>+</div>"
|
196
|
+
elsif @phrase[0] == @poem[@stanza_current].length - 1
|
197
|
+
result_text = "<div class='plus-button'>+</div>" + show_current_section
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
# Builds for Stanza with more than two sections and more than one phrase
|
203
|
+
if @poem[@stanza_current].length > 3
|
204
|
+
if @phrase.length > 1
|
205
|
+
# current_phrase is first in stanza and the second pharse is also displayed
|
206
|
+
if @phrase[0] == 1 && @section_current == 1 && @phrase[1] == 2
|
207
|
+
result_text = show_current_section + show_next_section + "<div class='minus-button'>-</div>"
|
208
|
+
end
|
209
|
+
# current_phrase is the last phrase in the stanza and the previous phrase is also displayed
|
210
|
+
if @phrase.last == @section_current && @phrase[@phrase.length - 2] == @section_current -1
|
211
|
+
result_text = "<div class='minus-button'>-</div>#{show_previous_section}#{show_current_section}"
|
212
|
+
end
|
213
|
+
# there are two phrases in array, current_phrase is not first or last stanza,
|
214
|
+
# and current_phrase > second phrase
|
215
|
+
if @phrase.length == 2 && @section_current != 1 && @section_current != @poem[@stanza_current].length - 1
|
216
|
+
result_text = "<div class='minus-button'>-</div>#{show_previous_section}#{show_current_section}<div class='plus-button'>+</div>"
|
217
|
+
end
|
218
|
+
# there are two phrases in array, current_phrase is not first or last,
|
219
|
+
# and current_phrase < second phrase
|
220
|
+
if @phrase.length == 2 && @section_current != 1 \
|
221
|
+
&& @section_current != @poem[@stanza_current].length - 1 \
|
222
|
+
&& @phrase.last > @section_current
|
223
|
+
result_text = "<div class='plus-button'>+</div>#{show_current_section}#{show_next_section}<div class='minus-button'>-</div>"
|
224
|
+
end
|
225
|
+
# three phrases in the phrase storage array
|
226
|
+
if @phrase.length == 3
|
227
|
+
result_text = "<div class='minus-button'>+</div>#{show_previous_section}#{show_current_section}#{show_next_section}<div class='minus-button'>-</div>"
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
end
|
233
|
+
# show result
|
234
|
+
result_text
|
235
|
+
end
|
184
236
|
|
185
237
|
def init_poem
|
186
238
|
declare_instance_variables
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quote_machine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Chapman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|