Sha256: 5e770a727eafcc436fcacb4c646ba84d461249edaa1558d9396b97d6d62ffd5f

Contents?: true

Size: 1014 Bytes

Versions: 6

Compression:

Stored size: 1014 Bytes

Contents

# frozen_string_literal: true

require 'ehbrs_ruby_utils/bga/parsers/table/options'
require 'ehbrs_ruby_utils/bga/urls'
require 'eac_ruby_utils/core_ext'

module EhbrsRubyUtils
  module Bga
    class Table
      include ::EhbrsRubyUtils::Bga::Urls
      enable_simple_cache
      common_constructor :data

      SET_ITEMS = %i[options players].freeze

      ([:id] + ::EhbrsRubyUtils::Bga::Parsers::Table.fields.map(&:name) - SET_ITEMS)
        .each do |field|
        define_method field do
          data.fetch(field)
        end
      end

      # @return [Boolean]
      def game_conceded?
        game_conceded
      end

      # @return [Addressable::URI]
      def url
        table_url(id)
      end

      private

      SET_ITEMS.each do |item|
        define_method "#{item}_uncached" do
          data.fetch(item).map do |item_data|
            self.class.const_get(item.to_s.singularize.camelize).new(self, item_data)
          end
        end
      end

      require_sub __FILE__
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ehbrs_ruby_utils-0.27.0 lib/ehbrs_ruby_utils/bga/table.rb
ehbrs_ruby_utils-0.26.0 lib/ehbrs_ruby_utils/bga/table.rb
ehbrs_ruby_utils-0.25.1 lib/ehbrs_ruby_utils/bga/table.rb
ehbrs_ruby_utils-0.25.0 lib/ehbrs_ruby_utils/bga/table.rb
ehbrs_ruby_utils-0.24.1 lib/ehbrs_ruby_utils/bga/table.rb
ehbrs_ruby_utils-0.24.0 lib/ehbrs_ruby_utils/bga/table.rb