Class: Sheet

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/solis/shape/reader/simple_sheets/sheet.rb

Instance Method Summary collapse

Constructor Details

#initialize(worksheet) ⇒ Sheet

Returns a new instance of Sheet.



3
4
5
6
# File 'lib/solis/shape/reader/simple_sheets/sheet.rb', line 3

def initialize(worksheet)
  @worksheet = worksheet
  @last_sync = Time.now
end

Instance Method Details

#[](index) ⇒ Object



22
23
24
# File 'lib/solis/shape/reader/simple_sheets/sheet.rb', line 22

def [](index)
  row_as_record(@worksheet.rows(skip=0)[index])
end

#countObject



26
27
28
# File 'lib/solis/shape/reader/simple_sheets/sheet.rb', line 26

def count
  @worksheet.num_rows - 1
end

#eachObject



12
13
14
15
16
# File 'lib/solis/shape/reader/simple_sheets/sheet.rb', line 12

def each
  @worksheet.rows(skip=1).each do |row|
    yield make_record_from_row(row)
  end
end

#headerObject



18
19
20
# File 'lib/solis/shape/reader/simple_sheets/sheet.rb', line 18

def header
  @header ||= @worksheet.rows[0].map{|m| m.downcase.gsub(' ','_').gsub('#', '_hash').gsub('%','_percent')}
end

#titleObject



8
9
10
# File 'lib/solis/shape/reader/simple_sheets/sheet.rb', line 8

def title
  @worksheet.title
end