Class: TableParser::Table
- Inherits:
-
Object
- Object
- TableParser::Table
- Defined in:
- lib/table_parser/table.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Instance Method Summary collapse
-
#[](index) ⇒ Object
get column by index.
-
#initialize(doc, xpath_to_table = "//table[0]", options = {}) ⇒ Table
constructor
A new instance of Table.
- #to_s ⇒ Object
Constructor Details
#initialize(doc, xpath_to_table = "//table[0]", options = {}) ⇒ Table
Returns a new instance of Table.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/table_parser/table.rb', line 4 def initialize(doc, xpath_to_table="//table[0]", ={}) if .has_key?(:header) header = [:header] else header = true end if .has_key?(:dup_rows) dup_rows = [:dup_rows] else dup_rows = true end if .has_key?(:dup_cols) dup_cols = [:dup_cols] else dup_cols = true end table = Parser.extract_table(doc, xpath_to_table) @columns = Parser.extract_column_headers(table, dup_rows, dup_cols, header) @nodes = Parser.extract_nodes(table, @columns, dup_rows, dup_cols) end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
3 4 5 |
# File 'lib/table_parser/table.rb', line 3 def columns @columns end |
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
3 4 5 |
# File 'lib/table_parser/table.rb', line 3 def nodes @nodes end |
Instance Method Details
#[](index) ⇒ Object
get column by index
33 34 35 |
# File 'lib/table_parser/table.rb', line 33 def [](index) @columns[index] end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/table_parser/table.rb', line 28 def to_s "Table<#{@columns.collect{|h| h.to_s }.join(",")}>" end |