Sha256: e73f413c3c64d98cde6719d48591880e047a17fdf6596f19981f728addf085bd

Contents?: true

Size: 939 Bytes

Versions: 1

Compression:

Stored size: 939 Bytes

Contents

module TP
  class SlideDeck
    attr_accessor :cursor, :slides

    def initialize(slides)
      self.cursor = 0
      self.slides = slides
    end

    def [](index)
      frames[index]
    end

    def current
      frames[cursor]
    end
    alias current_frame current

    def ended?
      not current
    end

    def frames
      return @frames if @frames

      @frames = []

      slides.each do |slide|
        if slide.bullets
          buffer = "# #{slide.header}"

          @frames << Slide.new(buffer)

          buffer << "\n"

          slide.bullets.each do |bullet|
            buffer << "\n* #{bullet}"
            @frames << Slide.new(buffer)
          end
        else
          @frames << Slide.new("# #{slide.header}\n\n#{slide.body}")
        end
      end

      @frames
    end

    def next
      self.cursor += 1

      current
    end

    def previous
      self.cursor -= 1

      current
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tp-0.3.0 lib/tp/slide_deck.rb