class HS::Course

{HS::Course} is a top level model for a course.

Attributes

chapters[R]
slug[RW]
title[RW]

Public Class Methods

load(file) click to toggle source

Load course from given XML file.

# File lib/hs/models/course.rb, line 11
def self.load(file)
  dir = File.dirname(file)

  load_course(File.read(file)) do |course, chapter_file|
    path = "#{dir}/#{chapter_file}"
    course.chapters << HS::Chapter.load(course, path)
  end
end
new(args) click to toggle source
# File lib/hs/models/course.rb, line 23
def initialize(args)
  @chapters = []

  args.each do |key, val|
    instance_variable_set("@#{key}", val)
  end
end

Public Instance Methods

find_chapter(slug) click to toggle source

Tries to find chapter in this course by chapter slug.

# File lib/hs/models/course.rb, line 32
def find_chapter(slug)
  chapters.find { |c| c.slug.to_s == slug.to_s }
end
hs_url() click to toggle source

URL of this course when published.

# File lib/hs/models/course.rb, line 37
def hs_url
  "#{HS::Config.publish_url}/learn/#{slug}"
end