Class: HS::Chapter
- Inherits:
-
Object
- Object
- HS::Chapter
- Extended by:
- ChapterLoader
- Includes:
- ChapterPreview
- Defined in:
- lib/hs/models/chapter.rb
Constant Summary collapse
- REVIEW_STATUSES =
%w[none translated first second final].freeze
Constants included from ChapterPreview
HS::ChapterPreview::REVIEW_COLOR, HS::ChapterPreview::REVIEW_ICON, HS::ChapterPreview::REVIEW_TITLE
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#course ⇒ Object
readonly
Returns the value of attribute course.
-
#intro ⇒ Object
Returns the value of attribute intro.
- #review_status ⇒ Object
-
#slug ⇒ Object
Returns the value of attribute slug.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #hs_url ⇒ Object
-
#initialize(course, args) ⇒ Chapter
constructor
A new instance of Chapter.
Methods included from ChapterLoader
Methods included from ElementLoader
Methods included from XMLParser
Methods included from ChapterPreview
#preview, #review_color, #review_icon, #review_title
Methods included from HTMLPreview
Constructor Details
#initialize(course, args) ⇒ Chapter
Returns a new instance of Chapter.
21 22 23 24 25 26 27 28 |
# File 'lib/hs/models/chapter.rb', line 21 def initialize(course, args) @course = course @content = [] args.each do |key, val| instance_variable_set("@#{key}", val) end end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
17 18 19 |
# File 'lib/hs/models/chapter.rb', line 17 def content @content end |
#course ⇒ Object (readonly)
Returns the value of attribute course.
17 18 19 |
# File 'lib/hs/models/chapter.rb', line 17 def course @course end |
#intro ⇒ Object
Returns the value of attribute intro.
18 19 20 |
# File 'lib/hs/models/chapter.rb', line 18 def intro @intro end |
#review_status ⇒ Object
30 31 32 33 |
# File 'lib/hs/models/chapter.rb', line 30 def review_status return 'none' unless REVIEW_STATUSES.include?(@review_status) @review_status end |
#slug ⇒ Object
Returns the value of attribute slug.
18 19 20 |
# File 'lib/hs/models/chapter.rb', line 18 def slug @slug end |
#title ⇒ Object
Returns the value of attribute title.
18 19 20 |
# File 'lib/hs/models/chapter.rb', line 18 def title @title end |
Class Method Details
.load(course, file) ⇒ Object
13 14 15 |
# File 'lib/hs/models/chapter.rb', line 13 def self.load(course, file) load_chapter(course, File.read(file)) end |
Instance Method Details
#hs_url ⇒ Object
35 36 37 |
# File 'lib/hs/models/chapter.rb', line 35 def hs_url "#{course.hs_url}/#{slug}" end |