Class: Martlet::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/martlet/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(email, password) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
12
13
# File 'lib/martlet/client.rb', line 7

def initialize(email, password)
  @agent = Mechanize.new
  @email = email.include?('@') ? email : "#{email}@mail.mcgill.ca"
  
  authenticator = Authenticator.new(@agent)
  authenticator.authenticate(@email, password)
end

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.



5
6
7
# File 'lib/martlet/client.rb', line 5

def email
  @email
end

Instance Method Details

#courses(semester, year) ⇒ Object



24
25
26
# File 'lib/martlet/client.rb', line 24

def courses(semester, year)
  schedule(semester, year).fetch_courses
end

#export_calendar(filename, courses) ⇒ Object



28
29
30
31
# File 'lib/martlet/client.rb', line 28

def export_calendar(filename, courses)
  exporter = CalendarExporter.new(filename, courses)
  exporter.export
end

#gradesObject



15
16
17
18
# File 'lib/martlet/client.rb', line 15

def grades
  transcript = Transcript.new(@agent)
  transcript.fetch_grades
end

#schedule(semester, year) ⇒ Object



20
21
22
# File 'lib/martlet/client.rb', line 20

def schedule(semester, year)
  Schedule.new(@agent, semester, year)
end