studi-budi 0.2.1 → 0.3.0
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/VERSION +1 -1
- data/lib/studi-budi.rb +26 -53
- data/spec/studi-budi_spec.rb +8 -9
- data/studi-budi.gemspec +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/studi-budi.rb
CHANGED
@@ -33,7 +33,6 @@ class StudiBudi
|
|
33
33
|
@collection_name = gets.chomp
|
34
34
|
puts "Enter the file path of your new collection (leave off the last \"/\"):"
|
35
35
|
@collection_path = gets.chomp
|
36
|
-
# something about setting up the collection hash & file here
|
37
36
|
@file = File.open("#{@collection_path}/#{@collection_name}.txt", "w+")
|
38
37
|
adding_cards
|
39
38
|
end
|
@@ -44,6 +43,7 @@ class StudiBudi
|
|
44
43
|
puts "Enter the file path of your existing collection (leave off the last \"/\"):"
|
45
44
|
@collection_path = gets.chomp
|
46
45
|
@file = File.open("#{@collection_path}/#{@collection_name}.txt", "a+")
|
46
|
+
@readlines_set = @file.readlines
|
47
47
|
menu
|
48
48
|
end
|
49
49
|
|
@@ -56,13 +56,10 @@ class StudiBudi
|
|
56
56
|
if pref == "1"
|
57
57
|
adding_cards
|
58
58
|
elsif pref == "2"
|
59
|
-
reviewing_cards
|
59
|
+
reviewing_cards
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
|
64
|
-
# so they're going to need to read the first line
|
65
|
-
|
66
63
|
def adding_cards
|
67
64
|
puts "Type the term you'd like to practice and its answer separated by a comma, then hit [enter]. This adds that 'card' to your collection. This will continue until BLAHBLAH To review your cards BLAHBLAHBLAH"
|
68
65
|
answer = gets.chomp
|
@@ -87,57 +84,33 @@ class StudiBudi
|
|
87
84
|
prompt = "Back: "
|
88
85
|
cards_correct = 0
|
89
86
|
cards_wrong = 0
|
90
|
-
puts "Let's review some of your cards.
|
91
|
-
|
92
|
-
|
93
|
-
# then make sure to always have it be an odd number, then can have current_card be a random key
|
94
|
-
# then do that number + 1 to get the value
|
95
|
-
readlines_set = @file.readlines
|
96
|
-
total_lines = readlines_set.size
|
97
|
-
# total_lines = @file.readlines.size
|
98
|
-
puts random_line = rand(0..total_lines)
|
99
|
-
puts answer_line = random_line + 1
|
100
|
-
until random_line % 2 == 0
|
101
|
-
random_line = rand(0..total_lines)
|
102
|
-
end
|
103
|
-
puts "card front: #{current_card = File.readlines(@file)[random_line]}"
|
104
|
-
user_answer = gets.chomp
|
105
|
-
if user_answer == readlines_set[answer_line] # @file.readlines[answer_line] # "#{random_line + 1}".to_i]
|
106
|
-
puts "CORRECT"
|
107
|
-
cards_correct += 1
|
108
|
-
else
|
109
|
-
puts "WRONG"
|
110
|
-
cards_wrong += 1
|
111
|
-
end
|
87
|
+
puts "Let's review some of your cards. How many incorrect answers to you want to enter before quitting because you failed?"
|
88
|
+
stop_at = gets.chomp.to_i
|
89
|
+
puts "Okay, we'll stop after #{stop_at} wrong answers."
|
112
90
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
# puts "it's odd"
|
117
|
-
# end
|
91
|
+
total_lines = (@readlines_set.size - 1)
|
92
|
+
random_line = rand(0..total_lines)
|
93
|
+
answer_line = random_line + 1
|
118
94
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
# end
|
95
|
+
while cards_wrong < stop_at
|
96
|
+
random_line = rand(0..total_lines)
|
97
|
+
until random_line % 2 == 0
|
98
|
+
random_line = rand(0..total_lines)
|
99
|
+
end
|
100
|
+
answer_line = random_line + 1
|
101
|
+
puts "What's on the back of this card?"
|
102
|
+
puts @readlines_set[random_line]
|
103
|
+
user_answer = gets.chomp
|
104
|
+
if user_answer == @readlines_set[answer_line].chomp
|
105
|
+
puts "CORRECT\n"
|
106
|
+
cards_correct += 1
|
107
|
+
else
|
108
|
+
puts "WRONG"
|
109
|
+
cards_wrong += 1
|
110
|
+
end
|
111
|
+
end
|
137
112
|
|
138
113
|
puts "You got #{cards_correct} flash cards correct. Good job!
|
139
114
|
Pst! You also got #{cards_wrong} flash cards wrong."
|
140
115
|
end
|
141
|
-
end
|
142
|
-
|
143
|
-
start = StudiBudi.new
|
116
|
+
end
|
data/spec/studi-budi_spec.rb
CHANGED
@@ -9,20 +9,19 @@ describe "StudiBudi" do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should get the user's input" do
|
12
|
-
@study_helper.stub!(:gets) {"
|
12
|
+
@study_helper.stub!(:gets) {"1"} # @study_helper.action.should eq
|
13
|
+
@study_helper.should_receive(:create)
|
13
14
|
end
|
14
15
|
|
16
|
+
it "should begin adding cards after creating a collection" do
|
17
|
+
@study_helper.create.should_receive(:adding_cards)
|
18
|
+
end
|
15
19
|
|
16
20
|
# "if I make a card collection called 'Potatos'" do
|
17
21
|
# adfld.@collection_name should_eq "Potatos"
|
18
22
|
# end
|
19
23
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
# I "should say I'm sorry I didn't finish this. I spent all my time on the .rb and that first test" do
|
25
|
+
# @sol.apology.should eq "Please forgive me"
|
26
|
+
# end
|
28
27
|
end
|
data/studi-budi.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: studi-budi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -95,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
95
|
version: '0'
|
96
96
|
segments:
|
97
97
|
- 0
|
98
|
-
hash:
|
98
|
+
hash: 2489389209653597560
|
99
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
100
|
none: false
|
101
101
|
requirements:
|