Class: DataTable
- Inherits:
-
Object
- Object
- DataTable
- Defined in:
- lib/source/data/data_table.rb
Instance Attribute Summary collapse
-
#st_count ⇒ Object
readonly
Returns the value of attribute st_count.
-
#str_count ⇒ Object
readonly
Returns the value of attribute str_count.
Instance Method Summary collapse
- #get_elem(str, st) ⇒ Object
-
#initialize(table) ⇒ DataTable
constructor
A new instance of DataTable.
- #to_my_array ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(table) ⇒ DataTable
Returns a new instance of DataTable.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/source/data/data_table.rb', line 7 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 |
Instance Attribute Details
#st_count ⇒ Object
Returns the value of attribute st_count.
5 6 7 |
# File 'lib/source/data/data_table.rb', line 5 def st_count @st_count end |
#str_count ⇒ Object
Returns the value of attribute str_count.
5 6 7 |
# File 'lib/source/data/data_table.rb', line 5 def str_count @str_count end |
Instance Method Details
#get_elem(str, st) ⇒ Object
19 20 21 22 23 |
# File 'lib/source/data/data_table.rb', line 19 def get_elem(str, st) return nil if str>=str_count return nil if st>=st_count table[str][st] end |
#to_my_array ⇒ Object
25 26 27 |
# File 'lib/source/data/data_table.rb', line 25 def to_my_array table.dup end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/source/data/data_table.rb', line 29 def to_s table.map { |row| "[#{row.join(', ')}]" }.join("\n") end |