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.



10
11
12
# File 'lib/cards/numbers_parser.rb', line 10

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

Instance Method Details

#default_output_fileObject



30
31
32
# File 'lib/cards/numbers_parser.rb', line 30

def default_output_file
  @table_name
end

#each_unparsed_rowObject



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

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

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