module UniaraVirtualParser::Services::Student

Public Instance Methods

student(token) click to toggle source
# File lib/uniara_virtual_parser/services/student.rb, line 4
def student(token)
  response = Client.get_with_token('/alunos/index/', token)
  parse_student_profile response.body
end

Private Instance Methods

parse_student_profile(html) click to toggle source
# File lib/uniara_virtual_parser/services/student.rb, line 11
def parse_student_profile(html)
  doc      = Nokogiri::HTML(html)
  name = doc.css("b:contains('Bom Dia')").first || 
    doc.css("b:contains('Boa Tarde')").first || doc.css("b:contains('Boa Noite')").first
  return '' unless name
  student  = Models::Student.new(name: name.text.match(/Bo[am] (Dia|Tarde|Noite), (.*)/)[2])
  student
end