Class: Review
- Inherits:
-
Object
- Object
- Review
- Defined in:
- lib/ogs_katacheck/review.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#engine ⇒ Object
Returns the value of attribute engine.
-
#engine_version ⇒ Object
Returns the value of attribute engine_version.
-
#full_review ⇒ Object
Returns the value of attribute full_review.
-
#game_id ⇒ Object
Returns the value of attribute game_id.
-
#id ⇒ Object
Returns the value of attribute id.
-
#moves ⇒ Object
Returns the value of attribute moves.
-
#network ⇒ Object
Returns the value of attribute network.
-
#network_size ⇒ Object
Returns the value of attribute network_size.
-
#number ⇒ Object
Returns the value of attribute number.
-
#strength ⇒ Object
Returns the value of attribute strength.
-
#type ⇒ Object
Returns the value of attribute type.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
-
#win_rate ⇒ Object
Returns the value of attribute win_rate.
Class Method Summary collapse
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(attributes, number:) ⇒ Review
constructor
A new instance of Review.
- #load_review ⇒ Object
Constructor Details
#initialize(attributes, number:) ⇒ Review
Returns a new instance of Review.
5 6 7 8 9 |
# File 'lib/ogs_katacheck/review.rb', line 5 def initialize(attributes, number:) attributes.each {|key, value| self.send(("#{key}="), value)} @number = number @@all << self end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
2 3 4 |
# File 'lib/ogs_katacheck/review.rb', line 2 def date @date end |
#engine ⇒ Object
Returns the value of attribute engine.
2 3 4 |
# File 'lib/ogs_katacheck/review.rb', line 2 def engine @engine end |
#engine_version ⇒ Object
Returns the value of attribute engine_version.
2 3 4 |
# File 'lib/ogs_katacheck/review.rb', line 2 def engine_version @engine_version end |
#full_review ⇒ Object
Returns the value of attribute full_review.
2 3 4 |
# File 'lib/ogs_katacheck/review.rb', line 2 def full_review @full_review end |
#game_id ⇒ Object
Returns the value of attribute game_id.
2 3 4 |
# File 'lib/ogs_katacheck/review.rb', line 2 def game_id @game_id end |
#id ⇒ Object
Returns the value of attribute id.
2 3 4 |
# File 'lib/ogs_katacheck/review.rb', line 2 def id @id end |
#moves ⇒ Object
Returns the value of attribute moves.
2 3 4 |
# File 'lib/ogs_katacheck/review.rb', line 2 def moves @moves end |
#network ⇒ Object
Returns the value of attribute network.
2 3 4 |
# File 'lib/ogs_katacheck/review.rb', line 2 def network @network end |
#network_size ⇒ Object
Returns the value of attribute network_size.
2 3 4 |
# File 'lib/ogs_katacheck/review.rb', line 2 def network_size @network_size end |
#number ⇒ Object
Returns the value of attribute number.
2 3 4 |
# File 'lib/ogs_katacheck/review.rb', line 2 def number @number end |
#strength ⇒ Object
Returns the value of attribute strength.
2 3 4 |
# File 'lib/ogs_katacheck/review.rb', line 2 def strength @strength end |
#type ⇒ Object
Returns the value of attribute type.
2 3 4 |
# File 'lib/ogs_katacheck/review.rb', line 2 def type @type end |
#uuid ⇒ Object
Returns the value of attribute uuid.
2 3 4 |
# File 'lib/ogs_katacheck/review.rb', line 2 def uuid @uuid end |
#win_rate ⇒ Object
Returns the value of attribute win_rate.
2 3 4 |
# File 'lib/ogs_katacheck/review.rb', line 2 def win_rate @win_rate end |
Class Method Details
.all ⇒ Object
11 12 13 |
# File 'lib/ogs_katacheck/review.rb', line 11 def self.all @@all end |
.destroy_all ⇒ Object
15 16 17 |
# File 'lib/ogs_katacheck/review.rb', line 15 def self.destroy_all self.all.clear end |
.find_by_number(number) ⇒ Object
19 20 21 |
# File 'lib/ogs_katacheck/review.rb', line 19 def self.find_by_number(number) @@all.find{|review| review.number == number} end |
Instance Method Details
#check ⇒ 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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/ogs_katacheck/review.rb', line 23 def check puts "Checking player submitted moves against #{@engine} #{@type} review ##{@id}..." review = load_review review.process # table = Terminal::Table.new title: "Results".bold, headings: ['Color'.bold, 'Tier'.bold, "#".bold, "%".bold] # x = 1 # while x < 4 do # table.add_row [x == 2 ? "Black".bold : nil, x, review.public_send("black_tier_#{x}")[0], review.public_send("black_tier_#{x}")[1].round(2)] # x += 1 # end # # table.add_separator # table.add_row [{:value => 'Total'.bold, :colspan => 2, :alignment => :center}, review.black_total[0], "#{review.black_total[1].round(2)}%"] # table.add_separator # table.add_separator # # x = 1 # while x < 4 do # table.add_row [x == 2 ? "White".bold : nil, x, review.public_send("black_tier_#{x}")[0], review.public_send("black_tier_#{x}")[1].round(2)] # x += 1 # end # # table.add_separator # # table.add_row [{:value => 'Total'.bold, :colspan => 2, :alignment => :center}, review.white_total[0], "#{review.white_total[1].round(2)}%"] # # table.style = {:width => 80, :padding_left => 3, :border_x => "=", :border_i => "x"} # # puts table table = Terminal::Table.new title: "Results".bold, headings: ['Tier'.bold, "#".bold, "%".bold] x = 1 table.add_row [{value: "Black".bold.light_white.on_black, alignment: :center, colspan: 3}] table.add_separator while x < 4 do table.add_row [x, {value: review.public_send("black_tier_#{x}")[0], alignment: :center}, {value: review.public_send("black_tier_#{x}")[1].round(2).to_s + " %", alignment: :center}] x += 1 end table.add_separator table.add_row [{:value => 'Total'.bold, :alignment => :center}, review.black_total[0], "#{review.black_total[1].round(2)}%"] table.add_separator table.add_row [{value: "White".bold.black.on_light_white.blink, alignment: :center, colspan: 3}] table.add_separator x = 1 while x < 4 do table.add_row [x, review.public_send("white_tier_#{x}")[0], review.public_send("white_tier_#{x}")[1].round(2).to_s + " %"] x += 1 end table.add_separator table.add_row [{:value => 'Total'.bold, :alignment => :center}, review.white_total[0], "#{review.white_total[1].round(2)}%"] table.style = {:width => 70, :padding_left => 2, :border_x => "=".blue, :border_i => "x".blue, :alignment => :center} puts table # puts "" # puts "^^ new" # puts "vv old" # puts "" # puts "-----------------------------------------------------" # puts "Black Tier 1 Moves: #{review.black_tier_1[0]} --- #{review.black_tier_1[1].round(2)}%" # puts "Black Tier 2 Moves: #{review.black_tier_2[0]} --- #{review.black_tier_2[1].round(2)}%" # puts "Black Tier 3 Moves: #{review.black_tier_3[0]} --- #{review.black_tier_3[1].round(2)}%" # puts "Black Tier 4 Moves: #{review.black_tier_4[0]} --- #{review.black_tier_4[1].round(2)}%" # puts "-----------------------------------------------------" # puts "White Tier 1 Moves: #{review.white_tier_1[0]} --- #{review.white_tier_1[1].round(2)}%" # puts "White Tier 2 Moves: #{review.white_tier_2[0]} --- #{review.white_tier_2[1].round(2)}%" # puts "White Tier 3 Moves: #{review.white_tier_3[0]} --- #{review.white_tier_3[1].round(2)}%" # puts "White Tier 4 Moves: #{review.white_tier_4[0]} --- #{review.white_tier_4[1].round(2)}%" # puts "-----------------------------------------------------" # puts "Black Total Top Moves: #{review.black_total[0]} --- #{review.black_total[1].round(2)}%" # puts "White Total Top Moves: #{review.white_total[0]} --- #{review.white_total[1].round(2)}%" # puts "-----------------------------------------------------" end |
#load_review ⇒ Object
105 106 107 |
# File 'lib/ogs_katacheck/review.rb', line 105 def load_review FullReview.new(JSON.parse(Faraday.get("https://online-go.com/termination-api/game/#{@game_id}/ai_review/#{@id}").body)) end |