Sha256: 6d97b535ac311e58ecb960293f0d0ce511da09f703701a5b0f048acb75f97108

Contents?: true

Size: 829 Bytes

Versions: 1

Compression:

Stored size: 829 Bytes

Contents

module SheetWrap
  class Worksheet
    extend Forwardable

    attr_reader :drive_worksheet, :headers, :rows

    def_delegator :@drive_worksheet, :title, :title
    def_delegator :@drive_worksheet, :title=, :title=
    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.1 lib/sheet_wrap/worksheet.rb