Class: FullReview
- Inherits:
-
Object
- Object
- FullReview
- Defined in:
- lib/ogs_katacheck/full_review.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#black_tier_1 ⇒ Object
Returns the value of attribute black_tier_1.
-
#black_tier_2 ⇒ Object
Returns the value of attribute black_tier_2.
-
#black_tier_3 ⇒ Object
Returns the value of attribute black_tier_3.
-
#black_tier_4 ⇒ Object
Returns the value of attribute black_tier_4.
-
#black_total ⇒ Object
Returns the value of attribute black_total.
-
#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.
-
#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.
-
#scores ⇒ Object
Returns the value of attribute scores.
-
#strength ⇒ Object
Returns the value of attribute strength.
-
#total_moves ⇒ Object
Returns the value of attribute total_moves.
-
#type ⇒ Object
Returns the value of attribute type.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
-
#white_tier_1 ⇒ Object
Returns the value of attribute white_tier_1.
-
#white_tier_2 ⇒ Object
Returns the value of attribute white_tier_2.
-
#white_tier_3 ⇒ Object
Returns the value of attribute white_tier_3.
-
#white_tier_4 ⇒ Object
Returns the value of attribute white_tier_4.
-
#white_total ⇒ Object
Returns the value of attribute white_total.
-
#win_rate ⇒ Object
Returns the value of attribute win_rate.
-
#win_rates ⇒ Object
Returns the value of attribute win_rates.
Class Method Summary collapse
Instance Method Summary collapse
- #calculate_percentages ⇒ Object
-
#initialize(attributes) ⇒ FullReview
constructor
A new instance of FullReview.
- #process ⇒ Object
Constructor Details
#initialize(attributes) ⇒ FullReview
Returns a new instance of FullReview.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ogs_katacheck/full_review.rb', line 7 def initialize(attributes) attributes.each {|key, value| self.send(("#{key}="), value)} @black_tier_1 = [0, 0] @black_tier_2 = [0, 0] @black_tier_3 = [0, 0] @black_tier_4 = [0, 0] @black_total = [0, 0] @white_total = [0, 0] @white_tier_1 = [0, 0] @white_tier_2 = [0, 0] @white_tier_3 = [0, 0] @white_tier_4 = [0, 0] @@all << self end |
Instance Attribute Details
#black_tier_1 ⇒ Object
Returns the value of attribute black_tier_1.
2 3 4 |
# File 'lib/ogs_katacheck/full_review.rb', line 2 def black_tier_1 @black_tier_1 end |
#black_tier_2 ⇒ Object
Returns the value of attribute black_tier_2.
2 3 4 |
# File 'lib/ogs_katacheck/full_review.rb', line 2 def black_tier_2 @black_tier_2 end |
#black_tier_3 ⇒ Object
Returns the value of attribute black_tier_3.
2 3 4 |
# File 'lib/ogs_katacheck/full_review.rb', line 2 def black_tier_3 @black_tier_3 end |
#black_tier_4 ⇒ Object
Returns the value of attribute black_tier_4.
2 3 4 |
# File 'lib/ogs_katacheck/full_review.rb', line 2 def black_tier_4 @black_tier_4 end |
#black_total ⇒ Object
Returns the value of attribute black_total.
2 3 4 |
# File 'lib/ogs_katacheck/full_review.rb', line 2 def black_total @black_total end |
#date ⇒ Object
Returns the value of attribute date.
2 3 4 |
# File 'lib/ogs_katacheck/full_review.rb', line 2 def date @date end |
#engine ⇒ Object
Returns the value of attribute engine.
2 3 4 |
# File 'lib/ogs_katacheck/full_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/full_review.rb', line 2 def engine_version @engine_version end |
#game_id ⇒ Object
Returns the value of attribute game_id.
2 3 4 |
# File 'lib/ogs_katacheck/full_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/full_review.rb', line 2 def id @id end |
#moves ⇒ Object
Returns the value of attribute moves.
2 3 4 |
# File 'lib/ogs_katacheck/full_review.rb', line 2 def moves @moves end |
#network ⇒ Object
Returns the value of attribute network.
2 3 4 |
# File 'lib/ogs_katacheck/full_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/full_review.rb', line 2 def network_size @network_size end |
#scores ⇒ Object
Returns the value of attribute scores.
2 3 4 |
# File 'lib/ogs_katacheck/full_review.rb', line 2 def scores @scores end |
#strength ⇒ Object
Returns the value of attribute strength.
2 3 4 |
# File 'lib/ogs_katacheck/full_review.rb', line 2 def strength @strength end |
#total_moves ⇒ Object
Returns the value of attribute total_moves.
2 3 4 |
# File 'lib/ogs_katacheck/full_review.rb', line 2 def total_moves @total_moves end |
#type ⇒ Object
Returns the value of attribute type.
2 3 4 |
# File 'lib/ogs_katacheck/full_review.rb', line 2 def type @type end |
#uuid ⇒ Object
Returns the value of attribute uuid.
2 3 4 |
# File 'lib/ogs_katacheck/full_review.rb', line 2 def uuid @uuid end |
#white_tier_1 ⇒ Object
Returns the value of attribute white_tier_1.
2 3 4 |
# File 'lib/ogs_katacheck/full_review.rb', line 2 def white_tier_1 @white_tier_1 end |
#white_tier_2 ⇒ Object
Returns the value of attribute white_tier_2.
2 3 4 |
# File 'lib/ogs_katacheck/full_review.rb', line 2 def white_tier_2 @white_tier_2 end |
#white_tier_3 ⇒ Object
Returns the value of attribute white_tier_3.
2 3 4 |
# File 'lib/ogs_katacheck/full_review.rb', line 2 def white_tier_3 @white_tier_3 end |
#white_tier_4 ⇒ Object
Returns the value of attribute white_tier_4.
2 3 4 |
# File 'lib/ogs_katacheck/full_review.rb', line 2 def white_tier_4 @white_tier_4 end |
#white_total ⇒ Object
Returns the value of attribute white_total.
2 3 4 |
# File 'lib/ogs_katacheck/full_review.rb', line 2 def white_total @white_total end |
#win_rate ⇒ Object
Returns the value of attribute win_rate.
2 3 4 |
# File 'lib/ogs_katacheck/full_review.rb', line 2 def win_rate @win_rate end |
#win_rates ⇒ Object
Returns the value of attribute win_rates.
2 3 4 |
# File 'lib/ogs_katacheck/full_review.rb', line 2 def win_rates @win_rates end |
Class Method Details
.all ⇒ Object
23 24 25 |
# File 'lib/ogs_katacheck/full_review.rb', line 23 def self.all @@all end |
.destroy_all ⇒ Object
27 28 29 |
# File 'lib/ogs_katacheck/full_review.rb', line 27 def self.destroy_all self.all.clear end |
Instance Method Details
#calculate_percentages ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ogs_katacheck/full_review.rb', line 31 def calculate_percentages white_moves = (@total_moves / 2.0).floor black_moves = (@total_moves / 2.0).ceil @black_tier_1[1] = @black_tier_1[0].to_f / black_moves * 100 @black_tier_2[1] = @black_tier_2[0].to_f / black_moves * 100 @black_tier_3[1] = @black_tier_3[0].to_f / black_moves * 100 @black_tier_4[1] = @black_tier_4[0].to_f / black_moves * 100 @white_tier_1[1] = @white_tier_1[0].to_f / white_moves * 100 @white_tier_2[1] = @white_tier_2[0].to_f / white_moves * 100 @white_tier_3[1] = @white_tier_3[0].to_f / white_moves * 100 @white_tier_4[1] = @white_tier_4[0].to_f / white_moves * 100 @black_total[0] = @black_tier_1[0] + @black_tier_2[0] + @black_tier_3[0] + @black_tier_4[0] @white_total[0] = @white_tier_1[0] + @white_tier_2[0] + @white_tier_3[0] + @white_tier_4[0] @white_total[1] = @white_tier_1[1] + @white_tier_2[1] + @white_tier_3[1] + @white_tier_4[1] @black_total[1] = @black_tier_1[1] + @black_tier_2[1] + @black_tier_3[1] + @black_tier_4[1] end |
#process ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ogs_katacheck/full_review.rb', line 52 def process @total_moves = @moves.count; @moves.each do |move| current_move = move[1]["move_number"] previous_move = @moves[(current_move.to_i - 1).to_s] move_made = move[1]["move"] if current_move.to_i >= 2 if previous_move["branches"][0]["moves"][0] == move_made current_move % 2 == 0 ? @white_tier_1[0] += 1 : @black_tier_1[0] += 1 elsif previous_move["branches"].count >= 2 && previous_move["branches"][1]["moves"][0] == move_made current_move % 2 == 0 ? @white_tier_2[0] += 1 : @black_tier_2[0] += 1 elsif previous_move["branches"].count >= 3 && previous_move["branches"][2]["moves"][0] == move_made current_move % 2 == 0 ? @white_tier_3[0] += 1 : @black_tier_3[0] += 1 elsif previous_move["branches"].count >= 4 && previous_move["branches"][3]["moves"][0] == move_made current_move % 2 == 0 ? @white_tier_4[0] += 1 : @black_tier_4[0] += 1 end end end calculate_percentages end |