Class: Textbringer::Presentation::SlideList

Inherits:
Object
  • Object
show all
Defined in:
lib/textbringer/presentation/slide_list.rb

Instance Method Summary collapse

Constructor Details

#initialize(s) ⇒ SlideList

Returns a new instance of SlideList.



16
17
18
19
20
21
22
# File 'lib/textbringer/presentation/slide_list.rb', line 16

def initialize(s)
  @list = s.scan(/^#+ *(.*?)\n(.*?)(?:(?=^#)|\z)/m).map.with_index {
    |(title, body), i|
    Slide.new(i + 1, title.strip, body.strip)
  }
  @index = 0
end

Instance Method Details

#backward_slideObject



38
39
40
41
42
# File 'lib/textbringer/presentation/slide_list.rb', line 38

def backward_slide
  if @index > 0
    @index -= 1
  end
end

#currentObject



28
29
30
# File 'lib/textbringer/presentation/slide_list.rb', line 28

def current
  @list[@index]
end

#forward_slideObject



32
33
34
35
36
# File 'lib/textbringer/presentation/slide_list.rb', line 32

def forward_slide
  if @index < @list.size - 1
    @index += 1
  end
end

#sizeObject



24
25
26
# File 'lib/textbringer/presentation/slide_list.rb', line 24

def size
  @list.size
end