Class: Mdextab::Tbody

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/mdextab/tbody.rb

Overview

TBODYトークン対応クラス

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lineno, mes) ⇒ Tbody

初期化

Parameters:

  • fname (String)

    構文解析対象のMarkdownファイル名

  • lineno (String)

    TBODYトークン出現行の行番号



23
24
25
26
27
28
29
30
# File 'lib/mdextab/tbody.rb', line 23

def initialize(lineno, mes)
  @array = []
  @tr = nil
  @th = nil
  @td = nil
  @lineno = lineno
  @mes = mes
end

Instance Attribute Details

#linenoInteger (readonly)

Returns TBODYトークン出現行の行番号.

Returns:

  • (Integer)

    TBODYトークン出現行の行番号



8
9
10
# File 'lib/mdextab/tbody.rb', line 8

def lineno
  @lineno
end

Instance Method Details

#add_td(lineno, content, nth, attr, condense) ⇒ void

This method returns an undefined value.

TDの追加

Parameters:

  • lineno (String)

    TDトークン出現行の行番号

  • content (String)

    TDトークンのコンテンツ

  • nth (Integer)

    TDトークンの出現順番

  • attr (String)

    TDトークンの属性

  • condense (Boolean)

    文字列化方法 true:改行を含めない false:改行を含める



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/mdextab/tbody.rb', line 61

def add_td(lineno, content, nth, attr, condense)
  @mes.output_debug("content=#{content}|nth=#{nth}|attr=#{attr}")
  # TRトークンが出現せずにTDトークンが出現したら、仮想的なTDトークンが出現したとみなす
  if nth == 1
    @tr = Tr.new(lineno)
    @array << @tr
  end
  @td = Td.new(lineno, attr)
  @td.add(content, condense)
  @tr.add(@td)
end

#add_th(lineno, content, nth, attr, condense) ⇒ void

This method returns an undefined value.

THの追加

Parameters:

  • lineno (String)

    THトークン出現行の行番号

  • content (String)

    THトークンのコンテンツ

  • nth (Integer)

    THトークンの出現順番

  • attr (String)

    THトークンの属性

  • condense (Boolean)

    文字列化方法 true:改行を含めない false:改行を含める



41
42
43
44
45
46
47
48
49
50
# File 'lib/mdextab/tbody.rb', line 41

def add_th(lineno, content, nth, attr, condense)
  # TRトークンが出現せずにTHトークンが出現したら、仮想的なTRトークンが出現したとみなす
  if nth == 1
    @tr = Tr.new(lineno)
    @array << @tr
  end
  @th = Th.new(lineno, attr)
  @th.add(content, condense)
  @tr.add(@th)
end

#finishvoid

This method returns an undefined value.

TBODYの追加終了



77
78
79
# File 'lib/mdextab/tbody.rb', line 77

def finish
  @tr = nil
end

#td_appendObject

See Also:



12
# File 'lib/mdextab/tbody.rb', line 12

def_delegator :@td, :add, :td_append

#th_appendObject

See Also:



16
# File 'lib/mdextab/tbody.rb', line 16

def_delegator :@th, :add, :th_append

#to_sString

tbodyの文字列化

Returns:

  • (String)

    HTMLのTBODYタグとして文字列化したもの



85
86
87
# File 'lib/mdextab/tbody.rb', line 85

def to_s
  ["<tbody>", @array.map(&:to_s), "</tbody>"].join("\n")
end