-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmethods.rb
More file actions
65 lines (56 loc) · 1.51 KB
/
methods.rb
File metadata and controls
65 lines (56 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# puts "Loaded up the methods file"
require "colorize"
require "espeak"
def output_group_size(number)
if number == 1
puts "There is one member in the group"
elsif number == 0
puts "The group is empty"
else
puts "There are #{number} members in the group"
end
end
def menu_input_select
puts "Press 1) to add a member to the group"
puts "Press 2) display a random group"
puts "Press 3) to select random user"
puts "Press 4) to quit"
#take input from user
menu_input = gets.chomp.to_i
return menu_input
end
def output_random_group_order(collection)
collection.shuffle.each_with_index do |name, index|
puts "#{index +1}. #{capitalize_multi_word_string(name)}".colorize(select_random_color)
sleep(1)
ESpeak::Speech.new(name).speak
end
end
def select_random_color
colours = String.colors.dup - [:black, :light_black]
return colours.sample
end
def add_member_to_group(arr)
puts "Enter name:"
name = gets.chomp
arr.push(name)
end
def capitalize_multi_word_string(str)
arr = str.split(" ")
capitalised_array = arr.map {|word| word.capitalize}
capitalised_string = capitalised_array.join(" ")
return capitalised_string
end
def wait_clear(time)
sleep(time)
system "clear"
end
def quit_program(group)
puts "type yes to quit"
quit_choice = gets.chomp.downcase
if quit_choice == 'yes'
group.save
puts "Updated #{group.name} thanks for using"
exit
end
end