Class: MyUW

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/myuw/errors.rb,
lib/myuw.rb,
lib/myuw/sln.rb,
lib/myuw/session.rb,
lib/myuw/schedule.rb,
lib/myuw/registration.rb

Overview

General purpose errors used within MyUW

Defined Under Namespace

Classes: InvalidPageError, InvalidSLNError, NotLoggedInError, Registration, RequestSLNTooSoonError, SLNInfo, Schedule, Session, TimeScheduleClosedError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMyUW

Returns a new instance of MyUW.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/myuw.rb', line 20

def initialize
  # Initialize the browser instance and mascarade
  # around as Safari on Mac
  @browser = WWW::Mechanize.new do |browser|
    browser.user_agent_alias = 'Mac Safari'
    browser.follow_meta_refresh = true
    
    # Workaround to avoid frozen object error SSL pages
    browser.keep_alive = false
    
    # Do not keep any history
    browser.max_history = 0
  end
  
  # Initialize other members
  @session = Session.new(self)
  @schedule = Schedule.new(self)
  @registration = Registration.new(self)
end

Instance Attribute Details

#browserObject

Returns the value of attribute browser.



15
16
17
# File 'lib/myuw.rb', line 15

def browser
  @browser
end

#registrationObject

Returns the value of attribute registration.



18
19
20
# File 'lib/myuw.rb', line 18

def registration
  @registration
end

#scheduleObject

Returns the value of attribute schedule.



17
18
19
# File 'lib/myuw.rb', line 17

def schedule
  @schedule
end

#sessionObject

Returns the value of attribute session.



16
17
18
# File 'lib/myuw.rb', line 16

def session
  @session
end

Instance Method Details

#login(user, pass) ⇒ Object

Log into MyUW with a given username and password



45
46
47
48
49
# File 'lib/myuw.rb', line 45

def (user, pass)
  @session.email = user
  @session.password = pass
  @session.
end

#sln(sln_number, term) ⇒ Object

Creates a new SLN object and returns it



52
53
54
55
56
57
# File 'lib/myuw.rb', line 52

def sln(sln_number, term)
  sln_obj = SLNInfo.new(self)
  sln_obj.sln = sln_number
  sln_obj.term = term
  return sln_obj
end