studi-budi 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -1
- data/VERSION +1 -1
- data/lib/studi-budi.rb +95 -34
- data/studi-budi.gemspec +1 -1
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
= studi-budi
|
2
2
|
|
3
|
-
|
3
|
+
Studi Budi allows you to create and save collections of "flash cards".
|
4
|
+
|
5
|
+
Once one of your collections has some cards in it, you can practice with them. Studi Budi will randomly cycle through the cards in your chosen collection and quiz you on them. When you're finished, it will tell you how many you got correct and how many you got wrong.
|
4
6
|
|
5
7
|
== Contributing to studi-budi
|
6
8
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/studi-budi.rb
CHANGED
@@ -7,30 +7,44 @@ class StudiBudi
|
|
7
7
|
2. Load"
|
8
8
|
action = gets.chomp
|
9
9
|
|
10
|
-
|
10
|
+
until (action == "1" or action == "2")
|
11
11
|
puts "Please enter '1' to create or '2' to load."
|
12
12
|
action = gets.chomp
|
13
|
-
|
13
|
+
end
|
14
14
|
if action == "1"
|
15
|
-
|
15
|
+
create
|
16
16
|
elsif action == "2"
|
17
|
-
|
18
|
-
|
19
|
-
"Please enter '1' to create or '2' to load."
|
20
|
-
|
17
|
+
load
|
18
|
+
end
|
21
19
|
end
|
22
20
|
|
21
|
+
##### could really just make one method for opening. don't need two for create/load
|
22
|
+
# def opening(create_or_load)
|
23
|
+
# puts "Enter the name of your new collection:"
|
24
|
+
# @collection_name = gets.chomp
|
25
|
+
# puts "Enter the file path of your new collection (leave off the last \"/\"):"
|
26
|
+
# @collection_path = gets.chomp
|
27
|
+
# # something about setting up the collection hash & file here
|
28
|
+
# @file = File.open("#{@collection_path}/#{collection_name}.rb", "r+")
|
29
|
+
# adding_cards
|
30
|
+
|
23
31
|
def create
|
24
32
|
puts "Enter the name of your new collection:"
|
25
33
|
@collection_name = gets.chomp
|
34
|
+
puts "Enter the file path of your new collection (leave off the last \"/\"):"
|
35
|
+
@collection_path = gets.chomp
|
26
36
|
# something about setting up the collection hash & file here
|
27
|
-
@
|
28
|
-
|
37
|
+
@file = File.open("#{@collection_path}/#{@collection_name}.txt", "w+")
|
38
|
+
adding_cards
|
29
39
|
end
|
30
40
|
|
31
41
|
def load
|
32
|
-
|
33
|
-
|
42
|
+
puts "Enter the name of your existing collection:"
|
43
|
+
@collection_name = gets.chomp
|
44
|
+
puts "Enter the file path of your existing collection (leave off the last \"/\"):"
|
45
|
+
@collection_path = gets.chomp
|
46
|
+
@file = File.open("#{@collection_path}/#{@collection_name}.txt", "a+")
|
47
|
+
menu
|
34
48
|
end
|
35
49
|
|
36
50
|
def menu
|
@@ -43,40 +57,87 @@ class StudiBudi
|
|
43
57
|
adding_cards
|
44
58
|
elsif pref == "2"
|
45
59
|
reviewing_cards # need to do same kind of thing as in initialize
|
46
|
-
|
60
|
+
end
|
47
61
|
end
|
48
62
|
|
63
|
+
|
64
|
+
# so they're going to need to read the first line
|
65
|
+
|
49
66
|
def adding_cards
|
50
|
-
puts "Type the term you'd like to practice and its
|
51
|
-
|
52
|
-
reviewing_cards
|
53
|
-
else
|
54
|
-
gets.chomp.split(",")
|
67
|
+
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
|
+
answer = gets.chomp
|
55
69
|
|
56
|
-
|
57
|
-
|
58
|
-
|
70
|
+
until answer == "review"
|
71
|
+
set = answer.split(",")
|
72
|
+
key = set[0]
|
73
|
+
value = set[1]
|
74
|
+
@file.write(key)
|
75
|
+
@file.write("\n")
|
76
|
+
@file.write(value)
|
77
|
+
@file.write("\n")
|
78
|
+
puts "Type the next term & answer:"
|
79
|
+
answer = gets.chomp
|
80
|
+
end
|
81
|
+
if answer == "review"
|
82
|
+
reviewing_cards
|
83
|
+
end
|
59
84
|
end
|
60
85
|
|
61
86
|
def reviewing_cards
|
87
|
+
prompt = "Back: "
|
88
|
+
cards_correct = 0
|
89
|
+
cards_wrong = 0
|
62
90
|
puts "Let's review some of your cards. To exit, simply hit [enter]."
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
91
|
+
# so need to count total lines (line count? google)
|
92
|
+
# need to set up a variable that will be a random number between 0 and max line number - 1
|
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
|
77
111
|
end
|
78
112
|
|
113
|
+
# if random_line % 2 == 0
|
114
|
+
# puts "it's even"
|
115
|
+
# else
|
116
|
+
# puts "it's odd"
|
117
|
+
# end
|
118
|
+
|
119
|
+
# total_lines = %x{wc -l '#{filename}'}.to_i
|
120
|
+
|
121
|
+
# until gets.chomp == nil
|
122
|
+
# cards_correct = 0
|
123
|
+
# cards_wrong = 0
|
124
|
+
|
125
|
+
# line_number =
|
126
|
+
|
127
|
+
# puts current_card = File.readlines(@file)[rand]
|
128
|
+
# user_answer = gets.chomp
|
129
|
+
# if user_answer == HASHHH[current_card]
|
130
|
+
# puts "CORRECT"
|
131
|
+
# cards_correct += 1
|
132
|
+
# else
|
133
|
+
# puts "WRONG"
|
134
|
+
# cards_wrong += 1
|
135
|
+
# end
|
136
|
+
# end
|
137
|
+
|
79
138
|
puts "You got #{cards_correct} flash cards correct. Good job!
|
80
139
|
Pst! You also got #{cards_wrong} flash cards wrong."
|
81
140
|
end
|
82
141
|
end
|
142
|
+
|
143
|
+
start = StudiBudi.new
|
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.2.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: 2348294695917239610
|
99
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
100
|
none: false
|
101
101
|
requirements:
|