class Mdextab::Th

THトークン対応クラス

Public Class Methods

new(lineno, attr=nil) click to toggle source

初期化

@param lineno [String] THトークン出現行の行番号 @param attr [String] THトークンの属性

# File lib/mdextab/th.rb, line 10
def initialize(lineno, attr=nil)
  @lineno = lineno
  @attr = attr
  @content = ""
end

Public Instance Methods

add(content, condense) click to toggle source

THトークンのコンテンツ追加

@param content [String] THトークンのコンテンツ @param condense [Boolean] 文字列化方法 true:改行を含めない false:改行を含める @return [void]

# File lib/mdextab/th.rb, line 22
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_s() click to toggle source

thの文字列化

@return [String] HTMLのTHタグとして文字列化したもの

# File lib/mdextab/th.rb, line 42
def to_s
  if @attr.nil?
    %Q(<th>#{@content}</th>)
  else
    %Q(<th #{@attr}>#{@content}</th>)
  end
end