Class: Mdextab::Tbody
- Inherits:
-
Object
- Object
- Mdextab::Tbody
- Extended by:
- Forwardable
- Defined in:
- lib/mdextab/tbody.rb
Overview
TBODYトークン対応クラス
Instance Attribute Summary collapse
-
#lineno ⇒ Integer
readonly
TBODYトークン出現行の行番号.
Instance Method Summary collapse
-
#add_td(lineno, content, nth, attr, condense) ⇒ void
TDの追加.
-
#add_th(lineno, content, nth, attr, condense) ⇒ void
THの追加.
-
#finish ⇒ void
TBODYの追加終了.
-
#initialize(lineno, mes) ⇒ Tbody
constructor
初期化.
- #td_append ⇒ Object
- #th_append ⇒ Object
-
#to_s ⇒ String
tbodyの文字列化.
Constructor Details
#initialize(lineno, mes) ⇒ 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
#lineno ⇒ Integer (readonly)
Returns 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の追加
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の追加
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 |
#finish ⇒ void
This method returns an undefined value.
TBODYの追加終了
77 78 79 |
# File 'lib/mdextab/tbody.rb', line 77 def finish @tr = nil end |
#td_append ⇒ Object
12 |
# File 'lib/mdextab/tbody.rb', line 12 def_delegator :@td, :add, :td_append |
#th_append ⇒ Object
16 |
# File 'lib/mdextab/tbody.rb', line 16 def_delegator :@th, :add, :th_append |
#to_s ⇒ String
tbodyの文字列化
85 86 87 |
# File 'lib/mdextab/tbody.rb', line 85 def to_s ["<tbody>", @array.map(&:to_s), "</tbody>"].join("\n") end |