Class: SheetWrap::Worksheet

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/sheet_wrap/worksheet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(drive_worksheet) ⇒ Worksheet

Returns a new instance of Worksheet.



15
16
17
18
# File 'lib/sheet_wrap/worksheet.rb', line 15

def initialize(drive_worksheet)
  @drive_worksheet = drive_worksheet
  load
end

Instance Attribute Details

#drive_worksheetObject (readonly)

Returns the value of attribute drive_worksheet.



5
6
7
# File 'lib/sheet_wrap/worksheet.rb', line 5

def drive_worksheet
  @drive_worksheet
end

#headersObject (readonly)

Returns the value of attribute headers.



5
6
7
# File 'lib/sheet_wrap/worksheet.rb', line 5

def headers
  @headers
end

#rowsObject (readonly)

Returns the value of attribute rows.



5
6
7
# File 'lib/sheet_wrap/worksheet.rb', line 5

def rows
  @rows
end

Instance Method Details

#loadObject



20
21
22
23
24
25
26
# File 'lib/sheet_wrap/worksheet.rb', line 20

def load
  @headers = (1..num_cols).map{|col| drive_worksheet[1, col] }

  @rows = (2..num_rows).map do |row|
    ::SheetWrap::Row.new(self, row)
  end
end

#reloadObject



28
29
30
31
# File 'lib/sheet_wrap/worksheet.rb', line 28

def reload
  @drive_worksheet.reload
  load
end