Class: CLI
- Inherits:
-
Object
show all
- Defined in:
- lib/what_is_this/CLI.rb
Defined Under Namespace
Classes: AdvancedSearch, Approx_Scraper, Dependencies, Install, Scraper, Scraper_Tools
Constant Summary
collapse
- @@spacing =
"\n\n\n"
- @@message_spacing =
" "
Class Method Summary
collapse
Class Method Details
.approximate_search ⇒ Object
55
56
57
58
59
60
|
# File 'lib/what_is_this/CLI.rb', line 55
def self.approximate_search
puts @@spacing + @@message_spacing + "Please input your search term:"
query = CGI.escape(gets.chomp.downcase.strip)
Approx_Scraper.get_approximate_data(query)
restart
end
|
.install ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/what_is_this/CLI.rb', line 67
def self.install
puts @@spacing + @@message_spacing + "Enter the gem that you would like to install and save as a dependency or back to return"
input = CGI.escape(gets.chomp)
case input
when 'back'
restart
else
Install.install(input)
end
restart
end
|
.introduction ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/what_is_this/CLI.rb', line 6
def self.introduction
introduction_message = '
$$\ $$\ $$\ $$\ $$\ $$\
$$ | $$ | \__| $$ | $$ | \__|
$$\ $$\ $$\ $$$$$$$\ $$$$$$\ $$$$$$\ $$\ $$$$$$$\ $$$$$$\ $$$$$$$\ $$\ $$$$$$$\
$$ | $$ | $$ |$$ __$$\ \____$$\ \_$$ _| $$$$$$\ $$ |$$ _____|$$$$$$\ \_$$ _| $$ __$$\ $$ |$$ _____|
$$ | $$ | $$ |$$ | $$ | $$$$$$$ | $$ | \______|$$ |\$$$$$$\ \______| $$ | $$ | $$ |$$ |\$$$$$$\
$$ | $$ | $$ |$$ | $$ |$$ __$$ | $$ |$$\ $$ | \____$$\ $$ |$$\ $$ | $$ |$$ | \____$$\
\$$$$$\$$$$ |$$ | $$ |\$$$$$$$ | \$$$$ | $$ |$$$$$$$ | \$$$$ |$$ | $$ |$$ |$$$$$$$ |
\_____\____/ \__| \__| \_______| \____/ \__|\_______/ \____/ \__| \__|\__|\_______/ '
introduction_message.each_char {|c| putc c ; sleep 0.0015}
puts @@spacing + @@message_spacing + "Welcome to what-is-this! To begin please type either dependencies, install, search or quit:"
start
end
|
.quit ⇒ Object
78
79
80
81
|
# File 'lib/what_is_this/CLI.rb', line 78
def self.quit
puts @@message_spacing + "Thanks for using 'what-is-this'... seeya!" + @@spacing
exit 1
end
|
.restart ⇒ Object
82
83
84
85
|
# File 'lib/what_is_this/CLI.rb', line 82
def self.restart
puts @@spacing + @@message_spacing + 'To continue, type either dependencies, install, search, or quit:'
start
end
|
.search ⇒ Object
61
62
63
64
65
66
|
# File 'lib/what_is_this/CLI.rb', line 61
def self.search
puts @@spacing + @@message_spacing + "Enter gem you would like to know about"
query = CGI.escape(gets.chomp.downcase.strip)
Scraper.getData(query)
restart
end
|
.start ⇒ Object
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
|
# File 'lib/what_is_this/CLI.rb', line 23
def self.start
input = CGI.escape(gets.chomp.downcase.strip)
puts @@spacing
case input
when 'search'
puts @@spacing + @@message_spacing + 'Would you like your search to be approximate(approx), advanced, exact or back to return?'
input = CGI.escape(gets.chomp.downcase.strip)
case input
when 'back'
self.restart
when 'approximate', 'approx'
approximate_search
when 'exact'
search
when 'advanced'
AdvancedSearch.advanced_search_properties
else
puts @@spacing + @@message_spacing + 'Command not recognised. Try again:'
restart
end
when 'install'
install
when 'dependencies'
Dependencies.display_dependencies
when 'quit'
quit
else
puts @@spacing + @@message_spacing + 'Command not recognised, try again!'
start
end
end
|