class CLI

Public Instance Methods

display_answer(result) click to toggle source

after a result is selected and the question has been displayed, this displays the result's full answer.

# File lib/askoverflow/cli.rb, line 64
def display_answer(result)
    4.times {visual_spacer}
    puts "++++++++++++++++++++++++++"
    puts "++++++++++ANSWER++++++++++"
    puts "++++++++++++++++++++++++++"
    puts "#{result.full_a}"
end
display_question(result) click to toggle source

after a result is selected, this displays the result's full question

# File lib/askoverflow/cli.rb, line 55
def display_question(result)
    10.times {visual_spacer}
    puts "++++++++++++++++++++++++++"
    puts "+++++++++QUESTION+++++++++"
    puts "++++++++++++++++++++++++++"
    puts "#{result.full_q}"
end
display_results() click to toggle source

Display functions, used to display data to the user display_results displays each result's basic info

# File lib/askoverflow/cli.rb, line 44
def display_results
    Result.all.each_with_index do |r, i|
        puts "++++++++++++++++++++++++++++++++++++++++++++++++++"
        puts "|ID:#{i + 1}| #{r.question.slice(0,60)}..."
        puts "|#{r.answer_count} answer(s) since: #{r.ask_date}"
        puts "|Tags:\t#{r.tags}"
        puts "++++++++++++++++++++++++++++++++++++++++++++++++++"
        puts ""
    end
end
goodbye() click to toggle source

displays a thankyou message for the user after exit

# File lib/askoverflow/cli.rb, line 7
def goodbye
    10.times {visual_spacer}
    puts "Thanks for using AskOverflow-"
    puts "I hope we helped"
    visual_spacer
end
greet() click to toggle source

greet, called at program start, greets the user

# File lib/askoverflow/cli.rb, line 3
def greet
    puts "askoverflow"
end
prompt_next() click to toggle source

after displaying the full question text asks user to press enter to display the answer

# File lib/askoverflow/cli.rb, line 36
def prompt_next
    visual_spacer
    puts "Press enter to read answer"
    visual_spacer
    gets
end
prompt_result() click to toggle source

asks user for the id number of their desired result

# File lib/askoverflow/cli.rb, line 24
def prompt_result
    puts "enter the id of a result to read further, back to do a new search or exit to quit"
end
prompt_return() click to toggle source

asks user to press enter to return to the results page

# File lib/askoverflow/cli.rb, line 28
def prompt_return
    visual_spacer
    puts "+++enter to return to results+++"
    visual_spacer
    gets
end
visual_spacer() click to toggle source

Helper function used to simplify displaying messages in a visually pleasing way

# File lib/askoverflow/cli.rb, line 15
def visual_spacer
    3.times {puts ""}
end