Class: EhbrsRubyUtils::Bga::Table

Inherits:
Object
  • Object
show all
Includes:
Urls
Defined in:
lib/ehbrs_ruby_utils/bga/table.rb,
lib/ehbrs_ruby_utils/bga/table/option.rb,
lib/ehbrs_ruby_utils/bga/table/player.rb,
lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters.rb,
lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/base.rb,
lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/ending.rb,
lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/beginning.rb,
lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/base/format_option.rb,
lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/base/format_player.rb,
lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/ending/format_player.rb,
lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/beginning/format_player.rb

Defined Under Namespace

Modules: WhatsappFormatters Classes: Option, Player

Constant Summary collapse

GAME_MODE_KEY =
'Modo de Jogo'
GAME_MODE_FRIENDLY_VALUE =
'Modo Amigável'
GAME_MODE_NORMAL_VALUE =
'Modo Normal'
SET_ITEMS =
i[options players].freeze

Constants included from Urls::InstanceMethods

Urls::InstanceMethods::ROOT_URL

Instance Method Summary collapse

Methods included from Urls::InstanceMethods

#build_url, #player_game_in_progress_url, #player_game_stats_url, #root_url, #table_url

Instance Method Details

#friendly?Boolean

Returns:



24
25
26
27
28
29
30
# File 'lib/ehbrs_ruby_utils/bga/table.rb', line 24

def friendly?
  value = option_value(GAME_MODE_KEY)
  return true if value == GAME_MODE_FRIENDLY_VALUE
  return false if value == GAME_MODE_NORMAL_VALUE

  raise "Unknown \"#{GAME_MODE_KEY}\" value: \"#{value}\""
end

#game_conceded?Boolean

Returns:



33
34
35
# File 'lib/ehbrs_ruby_utils/bga/table.rb', line 33

def game_conceded?
  game_conceded
end

#option_value(label) ⇒ String?

Parameters:

Returns:



39
40
41
# File 'lib/ehbrs_ruby_utils/bga/table.rb', line 39

def option_value(label)
  options.find { |o| o.label == label }.if_present(&:value)
end

#player_by_id(id) ⇒ EhbrsRubyUtils::Bga::Table::Player?

Parameters:

Returns:



45
46
47
# File 'lib/ehbrs_ruby_utils/bga/table.rb', line 45

def player_by_id(id)
  players.find { |p| p.id.to_s == id.to_s }
end

#urlAddressable::URI

Returns:



50
51
52
# File 'lib/ehbrs_ruby_utils/bga/table.rb', line 50

def url
  table_url(id)
end