Sha256: 894fbf6a3b699edceb681bd6ae885a080eb33a976a1f85ca7a16501768304a69
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
require 'travian_bot/application/navigate' class TravianBot class Application module Buildings include TravianBot::Application::Navigate def avaible_buildings(selenium) begin elements = selenium.find_elements(:xpath, '//map[@id="rx"]/area') resources = elements.inject([]) do |out, element| out << element.attribute('alt') out end rescue Selenium::WebDriver::Error::NoSuchElementError resources = [] end to_village_page(selenium) show_building_level(selenium) begin elements = selenium.find_elements(:xpath, '//div[@id="village_map"]/map/area') buildings = elements.inject([]) do |out, element| out << element.attribute('alt') out end rescue Selenium::WebDriver::Error::NoSuchElementError buildings = [] end resources + buildings end private def show_building_level(selenium) link = selenium.find_element(:xpath, '//img[@id="lswitch"]') link.click end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
travian_bot-0.2.0 | lib/travian_bot/application/buildings.rb |