Sha256: a1d72b164b0b7c8faf0c2128e1867e1c35c824cdcd597d90ea3c0ea983960a52

Contents?: true

Size: 729 Bytes

Versions: 1

Compression:

Stored size: 729 Bytes

Contents

module SheetWrap
  class Worksheet
    extend Forwardable

    attr_reader :drive_worksheet, :headers, :rows

    def_delegator :@drive_worksheet, :[], :[]
    def_delegator :@drive_worksheet, :[]=, :[]=
    def_delegator :@drive_worksheet, :num_cols, :num_cols
    def_delegator :@drive_worksheet, :num_rows, :num_rows
    def_delegator :@drive_worksheet, :save, :save

    def initialize(drive_worksheet)
      @drive_worksheet = drive_worksheet
      load
    end

    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

    def reload
      @drive_worksheet.reload
      load
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sheet_wrap-0.1.0 lib/sheet_wrap/worksheet.rb