Class: SGS::Wash
- Inherits:
-
Object
- Object
- SGS::Wash
- Defined in:
- lib/sgs/wash.rb
Instance Method Summary collapse
- #bookings ⇒ Object
- #initialize(args) ⇒ Wash constructor
Constructor Details
#initialize(args) ⇒ Wash
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/sgs/wash.rb', line 8 def initialize(args) @week = args[:week] || Date.today.cweek @cookies = SGS::Authenticate.new({ username: args.fetch(:username), password: args.fetch(:password) }). @booking = Struct.new(:group, :start_time, :end_time, :where) end |
Instance Method Details
#bookings ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/sgs/wash.rb', line 22 def bookings @_bookings ||= lambda { url = %W{ http://tvatta.sgsstudentbostader.se/wwwashbookings.aspx? panelId=616& weekoffset=0& date=#{URI.escape week_dates(@week).strftime("%Y-%m-%d %H:%M:%S")} }.join("") RestClient.get("http://www.sgsstudentbostader.se/ext_gw.aspx?module=wwwash&lang=se", cookies: @cookies) do |r| RestClient.get(r.headers[:location], cookies: @cookies) do |r| return prepare_data(RestClient.get(url, { cookies: r..merge(@cookies) })) end end }.call end |