Class: Cards::NumbersParser

Inherits:
Object show all
Includes:
TabularParser
Defined in:
lib/cards/numbers_parser.rb

Instance Method Summary collapse

Methods included from TabularParser

#denormalized_rows, #each_row, #rows

Constructor Details

#initialize(file, table_name) ⇒ NumbersParser

Returns a new instance of NumbersParser.



8
9
10
# File 'lib/cards/numbers_parser.rb', line 8

def initialize(file, table_name)
  @file, @table_name = file, table_name
end

Instance Method Details

#default_output_fileObject



28
29
30
# File 'lib/cards/numbers_parser.rb', line 28

def default_output_file
  @table_name
end

#each_unparsed_rowObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cards/numbers_parser.rb', line 12

def each_unparsed_row
  numbers = OSA.app('Numbers')
  document = numbers.open(@file)
  table = find_table(document, @table_name)

  table.rows.each do |row|
    values = []
    row.cells.map do |cell|
      value = cell.value
      value = nil if value == 0
      values << value
    end
    yield values
  end
end