Sha256: 44fd988779314739b93da4513c9511cd7add41c836bd51002d6d93e8db684051

Contents?: true

Size: 821 Bytes

Versions: 7

Compression:

Stored size: 821 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'

module EhbrsRubyUtils
  module Bga
    class GameStatistics
      class WhatsappFormatter
        class PlayerTitle
          acts_as_instance_method
          common_constructor :formatter, :player

          # @return [String]
          def result
            username_by_tables || player.name
          end

          # @return [String, nil]
          def username_by_tables
            formatter.with_players_tables.lazy.map { |table| username_by_table(table) }
              .find(&:present?)
          end

          # @param table [EhbrsRubyUtils::Bga::Table]
          # @return [String, nil]
          def username_by_table(table)
            table.player_by_id(player.id).if_present(&:name)
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ehbrs_ruby_utils-0.44.3 lib/ehbrs_ruby_utils/bga/game_statistics/whatsapp_formatter/player_title.rb
ehbrs_ruby_utils-0.44.2 lib/ehbrs_ruby_utils/bga/game_statistics/whatsapp_formatter/player_title.rb
ehbrs_ruby_utils-0.44.1 lib/ehbrs_ruby_utils/bga/game_statistics/whatsapp_formatter/player_title.rb
ehbrs_ruby_utils-0.44.0 lib/ehbrs_ruby_utils/bga/game_statistics/whatsapp_formatter/player_title.rb
ehbrs_ruby_utils-0.41.1 lib/ehbrs_ruby_utils/bga/game_statistics/whatsapp_formatter/player_title.rb
ehbrs_ruby_utils-0.41.0 lib/ehbrs_ruby_utils/bga/game_statistics/whatsapp_formatter/player_title.rb
ehbrs_ruby_utils-0.40.0 lib/ehbrs_ruby_utils/bga/game_statistics/whatsapp_formatter/player_title.rb