Class: Nopoint::Chapter

Inherits:
Object
  • Object
show all
Defined in:
lib/nopoint/chapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, file) ⇒ Chapter

Returns a new instance of Chapter.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/nopoint/chapter.rb', line 7

def initialize(id, file)
	@id = id
    @slides = []
    source = File.read(file)      
    if source =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
       # remove the matched header
       source = $'
       self.data = YAML.safe_load($1)
    else
      self.data = Hash.new
    end
    
    source.split(/\* ?\* ?\*/).each do |slide|
      @slides << Nopoint::Slide.new(slide)
    end
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



5
6
7
# File 'lib/nopoint/chapter.rb', line 5

def data
  @data
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/nopoint/chapter.rb', line 5

def id
  @id
end

#slidesObject

Returns the value of attribute slides.



5
6
7
# File 'lib/nopoint/chapter.rb', line 5

def slides
  @slides
end