Class: HaveTable::RowSequence

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/have_table/row_sequence.rb

Instance Method Summary collapse

Constructor Details

#initialize(table_node) ⇒ RowSequence

Returns a new instance of RowSequence.



5
6
7
8
9
10
# File 'lib/have_table/row_sequence.rb', line 5

def initialize(table_node)
  raise "did not receive a <table> node" unless table_node.name == "table"

  @tr_nodes = table_node.xpath("tr")
  read_header
end

Instance Method Details

#eachObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/have_table/row_sequence.rb', line 12

def each
  reset
  while true
    if is_on_header?
      next_row
      next
    end
    row = next_row
    break unless row
    yield(row)
  end
end