class MypageTools::CLI

Public Class Methods

help() click to toggle source
# File lib/mypage_tools/cli.rb, line 34
def self.help # hahaha
        puts ""
        puts "The only implemented feature currently is getting your schedule"
        puts ""
        puts "USAGE:"
        puts "\tmypage schedule"
        puts ""
end
parse_options(args=ARGV) click to toggle source
# File lib/mypage_tools/cli.rb, line 3
def self.parse_options args=ARGV
        case args[0]
        when "schedule"
                schedule
        when "help"
                self.help
        else
                puts "\nUnkown Argument\n"
                self.help
        end
end
schedule() click to toggle source
# File lib/mypage_tools/cli.rb, line 15
def self.schedule
        print `clear`
        puts "In order to get your work schedule you need to provide your login and password for myPage."
        print "Login: "
        ARGV.clear
        login = gets.chomp
        password = get_password
        puts "\n"
        scrape_session = ScheduleScraper.new login, password
        scrape_session.schedule_page
        while scrape_session.schedule_available?
                scrape_session.generate_schedule
                scrape_session.next_week
                break if scrape_session.no_schedule_available? # Loop not breaking w/out this line. Need to investigate.
        end
        puts "\nNo further schedules available."
        print `open #{Dir.home}/myPage\\ Schedule`
end

Private Class Methods

get_password() click to toggle source
# File lib/mypage_tools/cli.rb, line 45
def self.get_password
        print "Password: "
        STDIN.noecho(&:gets).chomp
end