Class: BnetScraper::Starcraft2::Status
- Inherits:
-
Object
- Object
- BnetScraper::Starcraft2::Status
- Defined in:
- lib/bnet_scraper/starcraft2/status_scraper.rb
Overview
Ask the TL.net bot if Battle.Net is currently online for a given region. This page is updated every 5 minutes. Call #fetch to refresh.
Examples:
BnetScraper::Starcraft2::Status.na => 'Online'
BnetScraper::Starcraft2::Status.fea => 'Offline'
BnetScraper::Starcraft2::Status.cn => nil (China is unsupported)
BnetScraper::Starcraft2::Status.fetch => [
{:region=>"North America", :status=>"Online"},{:region=>"Europe", :status=>"Online"},
{:region=>"Korea", :status=>"Online"}, {:region=>"South-East Asia", :status=>"Online"}
]
Constant Summary collapse
- SOURCE =
'http://www.teamliquid.net/forum/viewmessage.php?topic_id=138846'
Class Method Summary collapse
Class Method Details
.fetch ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/bnet_scraper/starcraft2/status_scraper.rb', line 19 def fetch response = Faraday.get SOURCE servers = Nokogiri::HTML(response.body).css('.forumPost').first.css('span').to_a servers.each_slice(2).map do |server_info| { region: server_info[0].text, status: server_info[1].text } end end |
.method_missing(sym) ⇒ Object
27 28 29 |
# File 'lib/bnet_scraper/starcraft2/status_scraper.rb', line 27 def method_missing sym status? sym if REGIONS.reject { |r| r == 'cn' }.include?(sym.to_s) end |