class GetSeo::CLI
CLI
Controller
Attributes
protocal[RW]
seo_data[RW]
start_of_program[RW]
Public Class Methods
new()
click to toggle source
# File lib/get_seo/cli.rb, line 6 def initialize @start_of_program = true end
Public Instance Methods
run_program()
click to toggle source
# File lib/get_seo/cli.rb, line 10 def run_program welcome_message check_requested_protocal get_seo_info seo_menu if start_of_program goodbye_message end
Private Instance Methods
check_requested_protocal()
click to toggle source
# File lib/get_seo/cli.rb, line 20 def check_requested_protocal loop do line_break puts "Check the webpage you would like to inspect and find out if it uses 'http' or 'https'?", "-To select 'http' (Enter 1)", "-To select 'https' (Enter 2)" requested_protocal = gets.strip.downcase if requested_protocal == '1' || requested_protocal == 'http' self.protocal = 'http://' break elsif requested_protocal == '2' || requested_protocal == 'https' self.protocal = 'https://' break else section_break puts "\t*Sorry but '#{requested_protocal}' is not a valid option.*" section_break end end end
get_seo_info()
click to toggle source
# File lib/get_seo/cli.rb, line 43 def get_seo_info line_break puts "In order to retrieve SEO information, please enter the domain of the webpage you would like to inspect (i.e. example.com):" print protocal # 'http://' or 'https://' requested_url = gets.strip.downcase # NOTE: Throw an exception if website cannote be accessed begin self.seo_data = GetSeo::Seo.setup(protocal + requested_url) rescue section_break puts "\t*There seems to be an issue with the domain you entered.*", "\t*Please double check the url and try again.*" section_break run_program end end
goodbye_message()
click to toggle source
# File lib/get_seo/cli.rb, line 116 def goodbye_message line_break puts "Great SEO work! Job well done." line_break end
line_break()
click to toggle source
# File lib/get_seo/cli.rb, line 142 def line_break puts "\n" end
print_seo_data(data_attr, name)
click to toggle source
# File lib/get_seo/cli.rb, line 122 def print_seo_data(data_attr, name) section_break puts "\t*#{name.upcase}*" section_break if data_attr.empty? puts "\t*#{name} - Not found on page.*" else data_attr.each do |value| puts "* #{value}" end end end
section_break()
click to toggle source
# File lib/get_seo/cli.rb, line 136 def section_break line_break 70.times { print '*' } line_break end
welcome_message()
click to toggle source
# File lib/get_seo/cli.rb, line 111 def welcome_message line_break puts "Welcome to SEO. Ok enough chitchat, let's get to work!" end