Class: Textbringer::Presentation::SlideList
- Inherits:
-
Object
- Object
- Textbringer::Presentation::SlideList
- Defined in:
- lib/textbringer/presentation/slide_list.rb
Instance Method Summary collapse
- #backward_slide ⇒ Object
- #current ⇒ Object
- #current_page ⇒ Object
- #forward_slide ⇒ Object
- #goto_page(no) ⇒ Object
-
#initialize(buffer) ⇒ SlideList
constructor
A new instance of SlideList.
- #size ⇒ Object
Constructor Details
#initialize(buffer) ⇒ SlideList
Returns a new instance of SlideList.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/textbringer/presentation/slide_list.rb', line 25 def initialize(buffer) @buffer = buffer doc = Commonmarker.parse(@buffer.to_s) @list = [] = nil i = 1 @buffer.save_excursion do doc.each do |node| if node.type == :heading @buffer.goto_line(node.source_position[:start_line]) .end_pos = @buffer.point - 1 if title = node.map { |c| c.string_content }.join.strip = Slide.new(@buffer, i, title) .start_pos = @buffer.point @list.push() i += 1 end end .end_pos = @buffer.point_max if end @index = @list.index { || .start_pos <= @buffer.point && @buffer.point <= .end_pos } || 0 end |
Instance Method Details
#backward_slide ⇒ Object
75 76 77 78 79 |
# File 'lib/textbringer/presentation/slide_list.rb', line 75 def if @index > 0 @index -= 1 end end |
#current ⇒ Object
54 55 56 |
# File 'lib/textbringer/presentation/slide_list.rb', line 54 def current @list[@index] end |
#current_page ⇒ Object
58 59 60 |
# File 'lib/textbringer/presentation/slide_list.rb', line 58 def current_page @index + 1 end |
#forward_slide ⇒ Object
69 70 71 72 73 |
# File 'lib/textbringer/presentation/slide_list.rb', line 69 def if @index < @list.size - 1 @index += 1 end end |
#goto_page(no) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/textbringer/presentation/slide_list.rb', line 62 def goto_page(no) if no < 1 || no > @list.size raise ArgumentError, "Invalid page number: #{no}" end @index = no - 1 end |
#size ⇒ Object
50 51 52 |
# File 'lib/textbringer/presentation/slide_list.rb', line 50 def size @list.size end |