class Grade

Public Class Methods

new(agent) click to toggle source
# File lib/academico.rb, line 33
def initialize(agent)
  @agent = agent
  @grade_selector =  'table > tbody tr:nth-child(2) > td > table > tbody > tr.conteudoTexto'
end

Public Instance Methods

create_table(rows) click to toggle source
# File lib/academico.rb, line 43
def create_table(rows)
  Terminal::Table.new :rows => rows,
                      :headings =>['Matéria', '1ºBi', '2ºBi', 'MS1', '3ºBi', '4ºBi', 'MS2', 'Final']
end
extract() click to toggle source
# File lib/academico.rb, line 52
def extract
  rows = []
  line = 1
  @agent.all(@grade_selector).each do |tr|
    all_tds = tr.all('td')
    info = []
    [0, 5, 7, 9, 12, 14, 18, 22].each do |field|
      n = all_tds[field].text
      if field != 0
        if n.to_f >= 6.0
          n = "\033[32m#{n}\033[m"
        else
          n = "\033[31m#{n}\033[m"
        end
      end
      info << n
    end
    rows << info
    line = line.next
  end
  rows
end
go_to_page() click to toggle source
# File lib/academico.rb, line 48
def go_to_page
  @agent.visit '/qacademico/index.asp?t=2032'
end
printable_grade() click to toggle source
# File lib/academico.rb, line 38
def printable_grade
  go_to_page
  create_table extract
end