Class: Facwparser::Element::TableData
- Inherits:
-
TableRow
- Object
- ElementBase
- TableRow
- Facwparser::Element::TableData
- Defined in:
- lib/facwparser/element.rb
Instance Attribute Summary collapse
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
Attributes inherited from ElementBase
Instance Method Summary collapse
-
#initialize(source, value) ⇒ TableData
constructor
A new instance of TableData.
- #render_html(options) ⇒ Object
Methods inherited from ElementBase
Constructor Details
#initialize(source, value) ⇒ TableData
Returns a new instance of TableData.
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/facwparser/element.rb', line 141 def initialize(source, value) super(source) @elements = [] element = '' s = StringScanner.new(value[1..-1]) in_link = false while s.rest? case when s.scan(/[^|\[\]]+/) || s.scan(/\\\[/) || s.scan(/\\\]/) || s.scan(/\\\|/) element += s[0] when s.scan(/\[/) in_link = true element += s[0] when s.scan(/\]/) in_link = false element += s[0] when s.scan(/\|/) if in_link element += s[0] else @elements << element element = '' end else element += s.rest break end end @elements << element if !element.empty? end |
Instance Attribute Details
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
140 141 142 |
# File 'lib/facwparser/element.rb', line 140 def elements @elements end |
Instance Method Details
#render_html(options) ⇒ Object
172 173 174 175 176 |
# File 'lib/facwparser/element.rb', line 172 def render_html() "<tr>" + @elements.map { |e| render_html_by_name_and_children('td', Parser.parse_value(e, ), ) }.join() + "</tr>" end |