Class: HS::Course
- Inherits:
-
Object
- Object
- HS::Course
- Extended by:
- CourseLoader
- Includes:
- CoursePreview
- Defined in:
- lib/hs/models/course.rb
Instance Attribute Summary collapse
-
#chapters ⇒ Object
readonly
Returns the value of attribute chapters.
-
#slug ⇒ Object
Returns the value of attribute slug.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #find_chapter(slug) ⇒ Object
- #hs_url ⇒ Object
-
#initialize(args) ⇒ Course
constructor
A new instance of Course.
Methods included from CourseLoader
Methods included from XMLParser
Methods included from CoursePreview
Methods included from HTMLPreview
Constructor Details
#initialize(args) ⇒ Course
Returns a new instance of Course.
23 24 25 26 27 28 29 |
# File 'lib/hs/models/course.rb', line 23 def initialize(args) args.each do |key, val| instance_variable_set("@#{key}", val) end @chapters = [] end |
Instance Attribute Details
#chapters ⇒ Object (readonly)
Returns the value of attribute chapters.
21 22 23 |
# File 'lib/hs/models/course.rb', line 21 def chapters @chapters end |
#slug ⇒ Object
Returns the value of attribute slug.
20 21 22 |
# File 'lib/hs/models/course.rb', line 20 def slug @slug end |
#title ⇒ Object
Returns the value of attribute title.
20 21 22 |
# File 'lib/hs/models/course.rb', line 20 def title @title end |
Class Method Details
.load(file) ⇒ Object
11 12 13 14 15 16 17 18 |
# 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 |
Instance Method Details
#find_chapter(slug) ⇒ Object
31 32 33 |
# File 'lib/hs/models/course.rb', line 31 def find_chapter(slug) chapters.find { |c| c.slug == slug } end |
#hs_url ⇒ Object
35 36 37 |
# File 'lib/hs/models/course.rb', line 35 def hs_url "#{HS::Config.publish_url}/learn/#{slug}" end |