Sha256: 525f3495a157ce86fa3dd1b6feb8fe9a0e80cd96fec84589877303211a8e798c

Contents?: true

Size: 469 Bytes

Versions: 3

Compression:

Stored size: 469 Bytes

Contents

module RenderAsMarkdown
  class Header

    def initialize title, char
      @title = [title.to_s.strip, " "].max
      @char  = char.to_s
    end

    def render
      length = [@title.length, 1].max
      @title << "\n" << @char*length << "\n"*2
    end

    alias_method :to_s, :render
  end

  class H1 < Header

    def initialize title
      super title, "="
    end

  end

  class H2 < Header

    def initialize title
      super title, "-"
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
render-as-markdown-0.0.6 lib/render-as-markdown/header.rb
render-as-markdown-0.0.5 lib/render-as-markdown/markdown-header.rb
render-as-markdown-0.0.4 lib/render-as-markdown/markdown-header.rb