Sha256: 9a8003cb3630e4bcb77b6a67904bd8c9db59d18b9fb93271f92525c4b0db7088

Contents?: true

Size: 527 Bytes

Versions: 7

Compression:

Stored size: 527 Bytes

Contents

require 'active_support/core_ext/object/deep_dup'
require 'csb/col'

module Csb
  class Cols
    include Enumerable

    attr_reader :cols

    def initialize
      @cols = []
    end

    def copy!(other)
      @cols = other.cols.deep_dup
    end

    def each(&block)
      cols.each(&block)
    end

    def add(*args, &block)
      cols << Col.new(*args, &block)
    end

    def headers
      map(&:name)
    end

    def values_by_item(item)
      map do |col|
        col.value_by_item(item)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
csb-0.3.1 lib/csb/cols.rb
csb-0.3.0 lib/csb/cols.rb
csb-0.2.4 lib/csb/cols.rb
csb-0.2.3 lib/csb/cols.rb
csb-0.2.2 lib/csb/cols.rb
csb-0.2.1 lib/csb/cols.rb
csb-0.2.0 lib/csb/cols.rb