Class: LogInto::HotSpot_Train
- Inherits:
-
Object
- Object
- LogInto::HotSpot_Train
- Defined in:
- lib/weblogin/providers/hotspot_train.rb
Instance Method Summary collapse
- #is_mine?(response) ⇒ Boolean
- #login(url, cookie, body) ⇒ Object
- #login_with_response(response) ⇒ Object
Instance Method Details
#is_mine?(response) ⇒ Boolean
6 7 8 |
# File 'lib/weblogin/providers/hotspot_train.rb', line 6 def is_mine? response response.args[:url] =~ /http:\/\/([a-zA-Z0-9.]+\.|)railnet.train/ end |
#login(url, cookie, body) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/weblogin/providers/hotspot_train.rb', line 18 def login url, , body # find out the real url of the rail site dom = Nokogiri::parse(body) redirecters = dom.css("meta").map{|i| i.attributes["content"]}.compact redirecter = redirecters[0].value referer_part = redirecter.match(/URL=(.*)/)[1] referer = URI::join(url, referer_part).to_s # load the rail site, say hello (just for the sake of saying hello) hotspot_train = RestClient.get referer, Cookie: # now load the hotspot (finally) LogInto::HotSpot.new.login referer, , body end |
#login_with_response(response) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/weblogin/providers/hotspot_train.rb', line 10 def login_with_response response # get some fields that are set anyway url = URI.parse(response.args[:url]) = response.args[:headers][:cookie] body = response.body login( url, , body ) end |