Class: Magister

Inherits:
Object
  • Object
show all
Includes:
MagisterData
Defined in:
lib/magister.rb

Overview

The main magister class

Instance Method Summary collapse

Methods included from MagisterData

#get_classes, #get_grades

Constructor Details

#initializeMagister

Returns a new instance of Magister.

Since:

  • 1.0.0



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/magister.rb', line 30

def initialize
    @profile = nil

    if $magister_useCache
        prev = ""
        $magister_cachingDirectory.split("/").each do |directory|
            Dir.mkdir(prev + directory) unless File.exist?(prev + directory)
            prev += directory + "/"
        end
    end
end

Instance Method Details

#authenticate(school, token) ⇒ Object

Create a new profile and authenticate with a token

Parameters:

  • school (String)

    The school the user attends

  • token (String)

    The users token

Since:

  • 1.0.0



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

def authenticate(school, token)
    @profile = Profile.new(token, school)
    @profile.verify
end

#login(school, username, password) ⇒ Object

Create a new profile based on a username and password

Parameters:

  • school (String)

    The school the user attends

  • username (String)

    The users username

  • password (String)

    The users password

See Also:

Since:

  • 1.1.0



56
57
58
59
# File 'lib/magister.rb', line 56

def (school, username, password)
    @profile = Authenticator.(username, password, school)
    @profile.verify
end

#profileProfile

Get the users profile

Returns:

Since:

  • 1.0.0



64
65
66
# File 'lib/magister.rb', line 64

def profile
    @profile
end