Sha256: 55befefa306a588d534ce6da89ed6355bdbda0654900e356d71766060c16cab8

Contents?: true

Size: 565 Bytes

Versions: 3

Compression:

Stored size: 565 Bytes

Contents

module TP
  class Slide
    attr_accessor :markdown

    def initialize(markdown)
      self.markdown = markdown.strip
    end

    def header
      line = lines.first
      line[1, line.length - 1].to_s.strip
    end

    def body
      result = lines[2, lines.count - 2]

      result.join "" if result
    end

    def bullets
      return unless body

      result = body.scan(/^\*\s+(.+)/).flatten

      result if result.any?
    end

    def paragraph
      body unless bullets
    end

    private

    def lines
      markdown.lines.to_a
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tp-0.3.0 lib/tp/slide.rb
tp-0.2.1 lib/tp/slide.rb
tp-0.2.0 lib/tp/slide.rb