Class: EhbrsRubyUtils::Bga::GameStatistics::WhatsappFormatter::PlayerContent
- Inherits:
-
Object
- Object
- EhbrsRubyUtils::Bga::GameStatistics::WhatsappFormatter::PlayerContent
- Defined in:
- lib/ehbrs_ruby_utils/bga/game_statistics/whatsapp_formatter/player_content.rb
Instance Method Summary collapse
- #rank_label(rank) ⇒ String
- #rank_percent(count) ⇒ String
- #rank_value(rank) ⇒ String
- #result ⇒ Hash<String, String>
Instance Method Details
#rank_label(rank) ⇒ String
22 23 24 |
# File 'lib/ehbrs_ruby_utils/bga/game_statistics/whatsapp_formatter/player_content.rb', line 22 def rank_label(rank) "#{rank}ยบ" end |
#rank_percent(count) ⇒ String
40 41 42 |
# File 'lib/ehbrs_ruby_utils/bga/game_statistics/whatsapp_formatter/player_content.rb', line 40 def rank_percent(count) (count * 100 / formatter.normal_tables.count).round end |
#rank_value(rank) ⇒ String
28 29 30 31 32 33 34 35 36 |
# File 'lib/ehbrs_ruby_utils/bga/game_statistics/whatsapp_formatter/player_content.rb', line 28 def rank_value(rank) count = 0 formatter.normal_tables.each do |table| count += 1 if table.player_by_id(player.id).if_present(false) do |v| v.rank == rank end end "#{count} (#{rank_percent(count)}%)" end |
#result ⇒ Hash<String, String>
14 15 16 17 18 |
# File 'lib/ehbrs_ruby_utils/bga/game_statistics/whatsapp_formatter/player_content.rb', line 14 def result formatter.ranks.to_h do |rank| [rank_label(rank), rank_value(rank)] end end |