Class: Mdextab::Table

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

Overview

Tableクラス

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lineno, mes, attr = nil) ⇒ Table

初期化

Parameters:

  • lineno (Integer)

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

  • mes (Messagex)

    Messagexクラスのインスタンス

  • sttr (String)

    TABLE_STARTトークンの属性



36
37
38
39
40
41
# File 'lib/mdextab/table.rb', line 36

def initialize(lineno, mes, attr=nil)
  @lineno = lineno
  @attr = attr
  @tbody = nil
  @mes = mes
end

Instance Attribute Details

#linenoObject (readonly)

Returns 入力Markdownファイル中のTABLEトークン出現行.

Returns:

  • 入力Markdownファイル中のTABLEトークン出現行



25
26
27
# File 'lib/mdextab/table.rb', line 25

def lineno
  @lineno
end

#tbodyObject (readonly)

Returns TABLE中のTBODYトークン出現行.

Returns:

  • TABLE中のTBODYトークン出現行



28
29
30
# File 'lib/mdextab/table.rb', line 28

def tbody
  @tbody
end

Instance Method Details

#:@tbodyObject



20
# File 'lib/mdextab/table.rb', line 20

def_delegators :@tbody, :add_th, :add_td, :td_append, :th_append, :add

#addObject

See Also:

  • Tbody#add


20
# File 'lib/mdextab/table.rb', line 20

def_delegators :@tbody, :add_th, :add_td, :td_append, :th_append, :add

#add_tbody(lineno) ⇒ void

This method returns an undefined value.

tbodyの追加

Parameters:

  • lineno (Integer)

    TBODY_STARTトークンまたは暗黙のtbodyの出現に係るトークンの出現行の行番号



48
49
50
# File 'lib/mdextab/table.rb', line 48

def add_tbody(lineno)
  @tbody = Tbody.new(lineno, @mes)
end

#add_tdObject



20
# File 'lib/mdextab/table.rb', line 20

def_delegators :@tbody, :add_th, :add_td, :td_append, :th_append, :add

#table_endString

tableの終了処理

Returns:

  • (String)

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



64
65
66
# File 'lib/mdextab/table.rb', line 64

def table_end
  to_s
end

#tbody_endvoid

This method returns an undefined value.

tbodyの終了処理



56
57
58
# File 'lib/mdextab/table.rb', line 56

def tbody_end
  @tbody.finish
end

#td_appendObject



20
# File 'lib/mdextab/table.rb', line 20

def_delegators :@tbody, :add_th, :add_td, :td_append, :th_append, :add

#th_appendObject



20
# File 'lib/mdextab/table.rb', line 20

def_delegators :@tbody, :add_th, :add_td, :td_append, :th_append, :add

#to_s(debug = false) ⇒ String

tableの文字列化

Parameters:

  • debug (Symbol) (defaults to: false)

    デバッグ用フラグ true: デバッグ情報を付加する false: デバッグ情報を付加しない

Returns:

  • (String)

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



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/mdextab/table.rb', line 73

def to_s(debug=false)
  if @attr
    if debug
      str = %Q(<table #{@attr} lineno:#{@lineno}>)
    else
      str = %Q(<table #{@attr}>)
    end
  elsif debug
    str = %Q(<table  lineno:#{@lineno}>)
  else
    str = %Q(<table>)
  end

  [str, @tbody.to_s, "</table>"].join("\n")
end