Sha256: dcc9b46c8ab47a64006fb52a0907f7098cab7c1c966d5c7bd83c2b3c04111c35

Contents?: true

Size: 991 Bytes

Versions: 4

Compression:

Stored size: 991 Bytes

Contents

# frozen_string_literal: true

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

module EhbrsRubyUtils
  module Bga
    class Session < ::SimpleDelegator
      class Table
        include ::EhbrsRubyUtils::Bga::Urls
        enable_method_class
        enable_simple_cache
        common_constructor :session, :table_id

        RESULTS_XPATH = '//*[@id = "game_result"]'

        def result
          ::EhbrsRubyUtils::Bga::Table.new(
            fetch_data
          )
        end

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

        private

        def fetch_data
          session.navigate.to url
          session.wait_for_element(xpath: RESULTS_XPATH)
          { id: table_id }.merge(
            ::EhbrsRubyUtils::Bga::Parsers::Table.from_content(session.current_source).data
          )
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ehbrs_ruby_utils-0.29.0 lib/ehbrs_ruby_utils/bga/session/table.rb
ehbrs_ruby_utils-0.28.0 lib/ehbrs_ruby_utils/bga/session/table.rb
ehbrs_ruby_utils-0.27.1 lib/ehbrs_ruby_utils/bga/session/table.rb
ehbrs_ruby_utils-0.27.0 lib/ehbrs_ruby_utils/bga/session/table.rb