Sha256: 7b1adf5d7ad49f5ee34a9233faa84c09870a40c4131a36f19072f5e5ba105667
Contents?: true
Size: 1.18 KB
Versions: 5
Compression:
Stored size: 1.18 KB
Contents
require 'travian_bot/application/navigation' class TravianBot class Application module Buildings include TravianBot::Application::Navigation 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
5 entries across 5 versions & 1 rubygems