class OsuCcScraper::University

Public Instance Methods

departments() click to toggle source
# File lib/osu-cc-scraper/university.rb, line 8
def departments
  html = fetch_departments
  parse_departments(html)
end

Private Instance Methods

fetch_departments() click to toggle source
# File lib/osu-cc-scraper/university.rb, line 15
def fetch_departments
  open("#{ENDPOINT}/CourseDescription.aspx").read
end
parse_department_name(row) click to toggle source
# File lib/osu-cc-scraper/university.rb, line 33
def parse_department_name(row)
  row.text[/([^(]+)/].strip
end
parse_department_subject_code(row) click to toggle source
# File lib/osu-cc-scraper/university.rb, line 29
def parse_department_subject_code(row)
  row.text[/\(.*?\)/][1..-2]
end
parse_departments(html) click to toggle source
# File lib/osu-cc-scraper/university.rb, line 19
def parse_departments(html)
  ng = Oga.parse_html(html)
  ng.xpath("//tr/td/font/a").map { |row|
    Department.new(
      parse_department_name(row),
      parse_department_subject_code(row),
    )
  }
end