Class: Mdextab::Th
- Inherits:
-
Object
- Object
- Mdextab::Th
- Defined in:
- lib/mdextab/th.rb
Overview
THトークン対応クラス
Instance Method Summary collapse
-
#add(content, condense) ⇒ void
THトークンのコンテンツ追加.
-
#initialize(lineno, attr = nil) ⇒ Th
constructor
初期化.
-
#to_s ⇒ String
thの文字列化.
Constructor Details
#initialize(lineno, attr = nil) ⇒ Th
初期化
10 11 12 13 14 |
# File 'lib/mdextab/th.rb', line 10 def initialize(lineno, attr=nil) @lineno = lineno @attr = attr @content = "" end |
Instance Method Details
#add(content, condense) ⇒ void
This method returns an undefined value.
THトークンのコンテンツ追加
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# 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 ⇒ String
thの文字列化
42 43 44 45 46 47 48 |
# 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 |