Created
October 11, 2013 15:54
-
-
Save TrevMcKendrick/6937219 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative './student_scraper' | |
require_relative './student' | |
class CLIstudent | |
attr_accessor :student_array, :input, :on | |
def initialize(student_array) | |
@on = true | |
end | |
def call | |
while self.on? | |
puts "Welcome to Flatron 003" | |
puts "Type a command! \n Your choices are: \n Browse \n Help \n Show \n Exit" | |
get_input | |
end | |
end | |
def on? | |
@on | |
end | |
def get_input | |
self.input = gets.strip.downcase | |
process_input | |
end | |
def process_input | |
case self.input | |
when "browse" | |
browse | |
when "help" | |
help | |
when "exit" | |
exit | |
when "show" | |
show | |
end | |
end | |
def browse | |
Student.all.each do |student| | |
puts "==========" | |
puts "Student name: #{student.name}" | |
puts "Twitter: #{student.twitter}" | |
puts "LinkedIn: #{student.linkedin}" | |
puts "Facebook: #{student.facebook}" | |
end | |
end | |
def help | |
puts "Here are a list of commands:" | |
puts "Browse" | |
puts "Show" | |
puts "Exit" | |
puts "Type 'help' to see this list again." | |
end | |
def exit | |
puts "Adios" | |
self.on = false | |
end | |
def show | |
puts "Provide an ID number:" | |
id = gets | |
student = Student.find(id.to_i).name | |
puts "--------------------------------------" | |
puts "Student id number #{id} is: #{student}" | |
puts "--------------------------------------" | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment