Class: HS::Module

Inherits:
Object
  • Object
show all
Extended by:
ModuleLoader
Includes:
ContentPreview, ReviewStatus
Defined in:
lib/hs/models/module.rb

Constant Summary

Constants included from ModuleLoader

HS::ModuleLoader::CUSTOM_LOADERS

Constants included from ReviewStatus

ReviewStatus::REVIEW_STATUSES

Constants included from ReviewStatusPreview

ReviewStatusPreview::REVIEW_COLOR, ReviewStatusPreview::REVIEW_ICON, ReviewStatusPreview::REVIEW_TITLE

Instance Attribute Summary collapse

Attributes included from ReviewStatus

#review_status

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ModuleLoader

load_module

Methods included from ElementLoader

#load_element, #load_elements

Methods included from XMLParser

#get_text, #parse_xml

Methods included from ContentPreview

#preview

Methods included from ReviewStatusPreview

#review_color, #review_icon, #review_title

Constructor Details

#initialize(chapter, args) ⇒ Module

Returns a new instance of Module.



20
21
22
23
24
25
26
27
# File 'lib/hs/models/module.rb', line 20

def initialize(chapter, args)
  @chapter = chapter
  @content = []

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

Instance Attribute Details

#chapterObject (readonly)

Returns the value of attribute chapter.



13
14
15
# File 'lib/hs/models/module.rb', line 13

def chapter
  @chapter
end

#contentObject (readonly)

Returns the value of attribute content.



13
14
15
# File 'lib/hs/models/module.rb', line 13

def content
  @content
end

#introObject

Returns the value of attribute intro.



14
15
16
# File 'lib/hs/models/module.rb', line 14

def intro
  @intro
end

#slugObject

Returns the value of attribute slug.



14
15
16
# File 'lib/hs/models/module.rb', line 14

def slug
  @slug
end

#titleObject

Returns the value of attribute title.



14
15
16
# File 'lib/hs/models/module.rb', line 14

def title
  @title
end

Class Method Details

.load(chapter, file) ⇒ Object



16
17
18
# File 'lib/hs/models/module.rb', line 16

def self.load(chapter, file)
  load_module(chapter, File.read(file))
end

Instance Method Details

#hs_urlObject

URL of this module when published.



30
31
32
# File 'lib/hs/models/module.rb', line 30

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