Class: RenderAsMarkdown::Header

Inherits:
Object
  • Object
show all
Defined in:
lib/render-as-markdown/header.rb

Direct Known Subclasses

H1, H2

Instance Method Summary collapse

Constructor Details

#initialize(title, char) ⇒ Header

Returns a new instance of Header.



4
5
6
7
# File 'lib/render-as-markdown/header.rb', line 4

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

Instance Method Details

#renderObject Also known as: to_s



9
10
11
12
# File 'lib/render-as-markdown/header.rb', line 9

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