Class: EhbrsRubyUtils::Bga::Parsers::Table::EndedPlayers
- Inherits:
-
Aranha::Parsers::Html::ItemList
- Object
- Aranha::Parsers::Html::ItemList
- EhbrsRubyUtils::Bga::Parsers::Table::EndedPlayers
- Defined in:
- lib/ehbrs_ruby_utils/bga/parsers/table/ended_players.rb
Constant Summary collapse
- ITEMS_XPATH =
'//div[starts-with(@id, "score_entry_")]'
- RANK_VALUES =
{ vencedor: 1, perdedor: 2 }.freeze
Instance Method Summary collapse
- #item_data(data) ⇒ Object
- #items_xpath ⇒ Object
- #process_elo_increment(expression) ⇒ Integer?
- #process_rank(source) ⇒ Integer
Instance Method Details
#item_data(data) ⇒ Object
31 32 33 34 35 |
# File 'lib/ehbrs_ruby_utils/bga/parsers/table/ended_players.rb', line 31 def item_data(data) %i[elo_increment rank].inject(data) do |a, e| a.merge(e => send("process_#{e}", data.fetch(e))) end end |
#items_xpath ⇒ Object
27 28 29 |
# File 'lib/ehbrs_ruby_utils/bga/parsers/table/ended_players.rb', line 27 def items_xpath ITEMS_XPATH end |
#process_elo_increment(expression) ⇒ Integer?
38 39 40 41 42 |
# File 'lib/ehbrs_ruby_utils/bga/parsers/table/ended_players.rb', line 38 def process_elo_increment(expression) return nil if expression.blank? ::Dentaku::Calculator.new.evaluate(expression.gsub(/\A\+/, '')).to_i end |
#process_rank(source) ⇒ Integer
46 47 48 |
# File 'lib/ehbrs_ruby_utils/bga/parsers/table/ended_players.rb', line 46 def process_rank(source) RANK_VALUES[source.downcase.to_sym] || source.to_i end |