Class: Obp::Access::TableMapper
- Inherits:
-
Object
- Object
- Obp::Access::TableMapper
- Defined in:
- lib/obp/access/table_mapper.rb
Overview
Maps the table-carrying nodes of an OBP preview HTML fragment — div.sts-table-wrap and div.sts-array, in document order — to a generic table model built from plain hashes, arrays and strings, ready for YAML serialization. This is an additive read of the same HTML source the Converter renders to STS XML; TableTermExtractor consumes this model.
Constant Summary collapse
- WRAP_SELECTOR =
Both wrapper kinds carry a single
.
"div.sts-table-wrap, div.sts-array"- SECTION_ID_PATTERN =
Section ids look like "toc_iso_std_iso_80000-12_ed-2_v2_en_sec_3"; the clause key is whatever follows "sec" ("3", "1.1", "index").
/_sec_(.+)\z/Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(source:) ⇒ TableMapper
constructor
A new instance of TableMapper.
- #tables ⇒ Object
- #to_yaml ⇒ Object
Constructor Details
#initialize(source:) ⇒ TableMapper
Returns a new instance of TableMapper.
24 25 26
# File 'lib/obp/access/table_mapper.rb', line 24 def initialize(source:) @source = source end
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
22 23 24
# File 'lib/obp/access/table_mapper.rb', line 22 def source @source end
Instance Method Details
#tables ⇒ Object
28 29 30
# File 'lib/obp/access/table_mapper.rb', line 28 def tables @tables ||= wraps.map { |node| map_table(node) } end
#to_yaml ⇒ Object
32 33 34
# File 'lib/obp/access/table_mapper.rb', line 32 def to_yaml tables.to_yaml end