Class: EhbrsRubyUtils::Bga::Parsers::GameInProgress
- Inherits:
-
Aranha::Parsers::Html::ItemList
- Object
- Aranha::Parsers::Html::ItemList
- EhbrsRubyUtils::Bga::Parsers::GameInProgress
- Defined in:
- lib/ehbrs_ruby_utils/bga/parsers/game_in_progress.rb
Constant Summary collapse
- DEFAULT_STATUS =
'asyncplay'
- ID_PARSER =
/table=(\d+)/.to_parser { |m| m[1].to_i }
- ITEMS_XPATH =
'//*[@id = "section-play"]//a[contains(@href, "table=")]'
- STATUS_CLASS_PATTERN =
/\Agametable_status_(.+)\z/.freeze
- STATUS_CLASS_PARSER =
STATUS_CLASS_PATTERN.to_parser { |m| m[1] }
- TABLE_COUNT_XPATH =
'//*[@id = "section-play"]/h1/span[contains(@class, "font-normal")]/span/text()'
Instance Method Summary collapse
- #data ⇒ Object
- #item_data(idd) ⇒ Object
- #items_xpath ⇒ Object
- #parse_id(href) ⇒ Integer
- #table_count ⇒ Integer
Instance Method Details
#data ⇒ Object
20 21 22 23 24 25 |
# File 'lib/ehbrs_ruby_utils/bga/parsers/game_in_progress.rb', line 20 def data { table_count: table_count, tables: items_data } end |
#item_data(idd) ⇒ Object
27 28 29 |
# File 'lib/ehbrs_ruby_utils/bga/parsers/game_in_progress.rb', line 27 def item_data(idd) { id: parse_id(idd.fetch(:href)), status: 'asyncplay' } end |
#items_xpath ⇒ Object
31 32 33 |
# File 'lib/ehbrs_ruby_utils/bga/parsers/game_in_progress.rb', line 31 def items_xpath ITEMS_XPATH end |
#parse_id(href) ⇒ Integer
37 38 39 |
# File 'lib/ehbrs_ruby_utils/bga/parsers/game_in_progress.rb', line 37 def parse_id(href) ID_PARSER.parse!(href) end |
#table_count ⇒ Integer
42 43 44 |
# File 'lib/ehbrs_ruby_utils/bga/parsers/game_in_progress.rb', line 42 def table_count nokogiri.at_xpath(TABLE_COUNT_XPATH).if_present(-1) { |v| v.text.to_i } end |