Class: HS::Chapter

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ChapterLoader

load_chapter

Methods included from ElementLoader

#load_element, #load_elements

Methods included from XMLParser

#get_text, #parse_xml

Methods included from ChapterPreview

#preview, #review_color, #review_icon, #review_title

Methods included from HTMLPreview

#html_preview

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

#contentObject (readonly)

Returns the value of attribute content.



17
18
19
# File 'lib/hs/models/chapter.rb', line 17

def content
  @content
end

#courseObject (readonly)

Returns the value of attribute course.



17
18
19
# File 'lib/hs/models/chapter.rb', line 17

def course
  @course
end

#introObject

Returns the value of attribute intro.



18
19
20
# File 'lib/hs/models/chapter.rb', line 18

def intro
  @intro
end

#review_statusObject



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

#slugObject

Returns the value of attribute slug.



18
19
20
# File 'lib/hs/models/chapter.rb', line 18

def slug
  @slug
end

#titleObject

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_urlObject



35
36
37
# File 'lib/hs/models/chapter.rb', line 35

def hs_url
  "#{course.hs_url}/#{slug}"
end