Class: Table

Inherits:
Object
  • Object
show all
Defined in:
lib/table.rb

Direct Known Subclasses

Stock, StockAttr

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data_hash) ⇒ Table

Returns a new instance of Table.



3
4
5
6
7
8
# File 'lib/table.rb', line 3

def initialize(data_hash)

  self.class.create_table_columns(data_hash)
  self.populate_table_columns(data_hash)

end

Class Method Details

.create_table_columns(data_hash) ⇒ Object



16
17
18
19
20
# File 'lib/table.rb', line 16

def self.create_table_columns(data_hash)
  data_hash.each do |key, value|
    attr_accessor key.to_sym
  end
end

Instance Method Details

#populate_table_columns(data_hash) ⇒ Object



10
11
12
13
14
# File 'lib/table.rb', line 10

def populate_table_columns(data_hash)
  data_hash.each do |key, value|
    self.send("#{key}=", value)
  end
end