3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/remote_table/file/html.rb', line 3
def each_row(&block)
backup_file!
convert_file_to_utf8!
remove_useless_characters!
= (.is_a?(Array)) ? : nil
Nokogiri::HTML(unescaped_html_without_soft_hyphens, nil, 'UTF-8').xpath(row_xpath).each do |row|
values = row.xpath(column_xpath).map { |td| td.content.gsub(/\s+/, ' ').strip }
if .nil?
= values
next
end
hash = zip , values
yield hash if keep_blank_rows or hash.any? { |k, v| v.present? }
end
ensure
restore_file!
end
|