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

Inherits:
Object
  • Object
show all
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
SECTION_SEPARATOR =
"\n\n"

Instance Method Summary collapse

Instance Method Details

#image_local_pathPathname

Returns:

  • (Pathname)


24
25
26
# File 'lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/base.rb', line 24

def image_local_path
  table.game.box_large_image.local_path
end

#optionsObject



59
60
61
# File 'lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/base.rb', line 59

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

#options_to_sObject



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

def options_to_s
  title_to_s('Opções') + options.join("\n")
end

#playersObject



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

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

#players_extraString

Returns:

  • (String)


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

def players_extra
  PLAYERS_EXTRA
end

#players_to_sString

Returns:

  • (String)


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

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

#root_items_to_sObject



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

def root_items_to_s
  title_to_s(root_items_title) + ROOT_ITENS.map { |k, v| "*#{k}*: #{table.send(v)}" }
                                   .join("\n")
end

#title_to_s(title) ⇒ Object



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

def title_to_s(title)
  "*#{[title_icon, title, title_icon].join(' ')}*\n\n"
end

#to_sObject



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

def to_s
  [root_items_to_s, players_to_s, options_to_s].map(&:strip).join(SECTION_SEPARATOR)
end