Class: EhbrsRubyUtils::Bga::Table::WhatsappFormatters::Base

Inherits:
Object
  • Object
show all
Includes:
WhatsappFormatter
Defined in:
lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/base.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

Direct Known Subclasses

Beginning, Ending

Defined Under Namespace

Classes: FormatOption, FormatPlayer

Constant Summary collapse

PLAYERS_EXTRA =
''
ROOT_ITENS =
{
  'Jogo' => :game_name,
  'Criada em' => :creation_time,
  'Duração' => :estimated_duration,
  'Endereço' => :url
}.freeze

Constants included from WhatsappFormatter

WhatsappFormatter::LINE_SEPARATOR, WhatsappFormatter::OPTION_SEPARATOR, WhatsappFormatter::SECTION_SEPARATOR

Instance Method Summary collapse

Methods included from WhatsappFormatter

#content_to_s, #game, #image_local_path, #options_to_s, #section_to_s, #title_icon, #title_to_s, #to_s

Instance Method Details

#optionsObject



54
55
56
# File 'lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/base.rb', line 54

def options
  table.options.map { |player| format_option(player) }
end

#playersObject



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

def players
  table.players.map { |player| format_player(player) }
end

#players_extraString

Returns:

  • (String)


41
42
43
# File 'lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/base.rb', line 41

def players_extra
  PLAYERS_EXTRA
end

#players_to_sString

Returns:

  • (String)


46
47
48
# File 'lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/base.rb', line 46

def players_to_s
  players_extra + players.join("\n")
end

#root_itemsHash

Returns:

  • (Hash)


36
37
38
# File 'lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/base.rb', line 36

def root_items
  ROOT_ITENS.transform_values { |v| table.send(v) }
end

#sectionsHash<String, String>

Returns “title” => “content”.

Returns:

  • (Hash<String, String>)

    “title” => “content”



27
28
29
30
31
32
33
# File 'lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/base.rb', line 27

def sections
  {
    root_items_title => root_items,
    players_title => players_to_s,
    'Opções' => options
  }
end