Class: CricosScrape::CourseImporter

Inherits:
Object
  • Object
show all
Defined in:
lib/cricos_scrape/importer/course_importer.rb

Constant Summary collapse

COURSE_URL =
'http://cricos.education.gov.au/Course/CourseDetails.aspx'

Instance Method Summary collapse

Constructor Details

#initialize(agent, **params) ⇒ CourseImporter

Returns a new instance of CourseImporter.



9
10
11
12
13
# File 'lib/cricos_scrape/importer/course_importer.rb', line 9

def initialize(agent, **params)
  @agent = agent
  @course_id = params.fetch(:course_id)
  @page = agent.get(url)
end

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/cricos_scrape/importer/course_importer.rb', line 15

def run
  return if course_not_found?

  course                    = Course.new
  course.course_id          = course_id
  course.course_name        = find_course_name
  course.course_code        = find_course_code
  course.dual_qualification = find_dual_qualification
  course.field_of_education = find_field_of_education
  course.broad_field        = find_education_broad_field
  course.narrow_field       = find_education_narrow_field
  course.detailed_field     = find_education_detailed_field
  course.course_level       = find_course_level
  course.foundation_studies = find_foundation_studies
  course.work_component     = find_work_component
  course.course_language    = find_course_language
  course.duration           = find_duration
  course.total_cost         = find_total_cost

  course.contact_officers   = find_contact_officers
  course.location_ids       = find_course_location

  course
end