Class: Mdextab::Th

Inherits:
Object
  • Object
show all
Defined in:
lib/mdextab/th.rb

Instance Method Summary collapse

Constructor Details

#initialize(lineno, attr = nil) ⇒ Th

Returns a new instance of Th.



3
4
5
6
7
# File 'lib/mdextab/th.rb', line 3

def initialize(lineno, attr=nil)
  @lineno = lineno
  @attr = attr
  @content = ""
end

Instance Method Details

#add(content, condense) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/mdextab/th.rb', line 9

def add(content, condense)
  if condense
    if @content
      if @content.match?(/^\s*$/)
        @content = content.to_s
      else
        @content += content.to_s
      end
    else
      @content = content.to_s
    end
  elsif content
    @content = [@content, content].join("\n")
  end
end

#to_sObject



25
26
27
28
29
30
31
# File 'lib/mdextab/th.rb', line 25

def to_s
  if @attr.nil?
    %Q(<th>#{@content}</th>)
  else
    %Q(<th #{@attr}>#{@content}</th>)
  end
end