Sha256: b2c9c5115dedcf538a117c9deec0d1037120402f908932a9f3983a07bed457a2

Contents?: true

Size: 853 Bytes

Versions: 7

Compression:

Stored size: 853 Bytes

Contents

require 'osheet/meta_element'
require 'osheet/column'
require 'osheet/row'

# this class is collects and validates worksheet meta-data.  It allows
# for storing a set of columns for referencing when building rows.  It is
# up to the writer to take this data and use it as needed.

module Osheet
  class Worksheet

    include MetaElement

    attr_reader :columns, :rows

    def initialize(name=nil, *args)
      @name = name
      @columns = []
      @rows = []
    end

    def name(value=nil)
      value.nil? ? @name : @name = value.to_s
    end

    def column(column_obj)
      @columns << column_obj
    end

    # Osheet only stores the latest row in memory for reference
    # memory bloat would be unmanageable in large spreadsheets if
    # all rows were stored
    def row(row_obj)
      @rows.pop
      @rows << row_obj
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
osheet-1.1.1 lib/osheet/worksheet.rb
osheet-1.1.0 lib/osheet/worksheet.rb
osheet-1.0.0 lib/osheet/worksheet.rb
osheet-1.0.0.rc.4 lib/osheet/worksheet.rb
osheet-1.0.0.rc.3 lib/osheet/worksheet.rb
osheet-1.0.0.rc.2 lib/osheet/worksheet.rb
osheet-1.0.0.rc.1 lib/osheet/worksheet.rb