Sha256: 5dbc90a1d46fb0596041b6293961bd0b8a6670a2287c7e1213411de6eecee3de

Contents?: true

Size: 667 Bytes

Versions: 2

Compression:

Stored size: 667 Bytes

Contents

# frozen_string_literal: true

class DataTable

  attr_reader :str_count, :st_count

  def initialize(table)
    self.str_count = table.length

    max_c=0
    table.each do |el|
      max_c = el.length if el.size > max_c
    end
    self.st_count = max_c
    self.table = table
  end


  def get_elem(str, st)
    return nil if str>=str_count
    return nil if st>=st_count
    table[str][st]
  end

  def each(&block)
    table.each do |row|
      block.call(row)
    end
  end

  def to_s
    table.map { |row| "[#{row.join(', ')}]" }.join("\n")
  end
  private
  attr_accessor :table
  attr_writer :str_count, :st_count

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shanti555890-1.1.5 lib/source/all_data/data_table.rb
shanti555890-1.1.4 lib/source/all_data/data_table.rb