Sha256: 28bbaa82460be3246b495994bcea428d112ef01379d1b284f4e21485e237fb79

Contents?: true

Size: 678 Bytes

Versions: 4

Compression:

Stored size: 678 Bytes

Contents

module TP
  class Renderer
    BULLET = "\u2022 "

    attr_accessor :slide

    def initialize(slide)
      self.slide = slide
    end

    def render
      Screen.clear!

      return unless slide

      buffer = slide.header.center Screen.width

      if slide.body
        buffer << "\n\n"

        if slide.paragraph
          paragraph = slide.paragraph.wrap Screen.width
          paragraph = paragraph.center Screen.width if paragraph.lines.one?

          buffer << paragraph
        else
          slide.bullets.each { |string| buffer << "#{BULLET}#{string}\n" }
        end
      end

      print buffer unless ENV['RUBY_ENV'] == 'test'

      true
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tp-0.3.1 lib/tp/renderer.rb
tp-0.3.0 lib/tp/renderer.rb
tp-0.2.1 lib/tp/renderer.rb
tp-0.2.0 lib/tp/renderer.rb