Class: OGSKataCheck::CLI
- Inherits:
-
Object
- Object
- OGSKataCheck::CLI
- Defined in:
- lib/ogs_katacheck/cli.rb
Instance Method Summary collapse
- #call ⇒ Object
- #check(check_id) ⇒ Object
- #get_reviews(game_id) ⇒ Object
- #show_farewell ⇒ Object
- #show_review_menu(game_id) ⇒ Object
Instance Method Details
#call ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ogs_katacheck/cli.rb', line 3 def call puts "Enter the Game ID you'd like to check for AI use:" game_id = gets.strip get_reviews(game_id) (game_id) check_id = gets.strip.to_i check(check_id) puts "" puts "Check another game? (Y/N)" input = gets.strip.downcase if input == "y" Review.destroy_all FullReview.destroy_all call else show_farewell end end |
#check(check_id) ⇒ Object
49 50 51 52 53 |
# File 'lib/ogs_katacheck/cli.rb', line 49 def check(check_id) puts "Processing. Please wait..." review = Review.find_by_number(check_id) review.check end |
#get_reviews(game_id) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/ogs_katacheck/cli.rb', line 23 def get_reviews(game_id) response = Faraday.get "https://online-go.com/api/v1/games/#{game_id}/ai_reviews" data = JSON.parse(response.body) data.each_with_index do |review, index| Review.new(review, number: index + 1) end end |
#show_farewell ⇒ Object
55 56 57 |
# File 'lib/ogs_katacheck/cli.rb', line 55 def show_farewell puts "Goodbye!" end |
#show_review_menu(game_id) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ogs_katacheck/cli.rb', line 32 def (game_id) puts "" puts "" puts "Game ID: #{game_id}" puts "" puts "The following reviews are available:" Review.all.each do |review| review.date = Time.new(review.date.slice(0,4), review.date.slice(5, 2), review.date.slice(8, 2), review.date.slice(11, 2), review.date.slice(14, 2), review.date.slice(17, 2), "+00:00") puts "#{review.number}. #{review.id} -- #{review.engine} -- #{review.type} -- #{review.date.localtime.strftime("%e %b %Y, %I:%M%p %Z")}" end puts "" puts "Enter the number of a review to check:" end |