Class: Flydata::Parser::SourceTable
- Inherits:
-
Object
- Object
- Flydata::Parser::SourceTable
- Defined in:
- lib/flydata/parser/source_table.rb
Instance Attribute Summary collapse
-
#column_names ⇒ Object
Returns the value of attribute column_names.
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#primary_keys ⇒ Object
Returns the value of attribute primary_keys.
-
#table_name ⇒ Object
Returns the value of attribute table_name.
-
#value_converters ⇒ Object
Returns the value of attribute value_converters.
Instance Method Summary collapse
- #add_column(column) ⇒ Object
-
#initialize(table_name, columns = {}, primary_keys = []) ⇒ SourceTable
constructor
A new instance of SourceTable.
- #set_value_converters(converter_hash) ⇒ Object
Constructor Details
#initialize(table_name, columns = {}, primary_keys = []) ⇒ SourceTable
Returns a new instance of SourceTable.
5 6 7 8 9 10 11 |
# File 'lib/flydata/parser/source_table.rb', line 5 def initialize(table_name, columns = {}, primary_keys = []) @table_name = table_name @columns = columns @column_names = columns.collect{|k,v| v[:column_name]} @primary_keys = primary_keys @value_converters = {} end |
Instance Attribute Details
#column_names ⇒ Object
Returns the value of attribute column_names.
13 14 15 |
# File 'lib/flydata/parser/source_table.rb', line 13 def column_names @column_names end |
#columns ⇒ Object
Returns the value of attribute columns.
13 14 15 |
# File 'lib/flydata/parser/source_table.rb', line 13 def columns @columns end |
#primary_keys ⇒ Object
Returns the value of attribute primary_keys.
13 14 15 |
# File 'lib/flydata/parser/source_table.rb', line 13 def primary_keys @primary_keys end |
#table_name ⇒ Object
Returns the value of attribute table_name.
13 14 15 |
# File 'lib/flydata/parser/source_table.rb', line 13 def table_name @table_name end |
#value_converters ⇒ Object
Returns the value of attribute value_converters.
13 14 15 |
# File 'lib/flydata/parser/source_table.rb', line 13 def value_converters @value_converters end |
Instance Method Details
#add_column(column) ⇒ Object
15 16 17 18 19 |
# File 'lib/flydata/parser/source_table.rb', line 15 def add_column(column) cn = column[:column_name] @columns[cn] = column @column_names << cn end |
#set_value_converters(converter_hash) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/flydata/parser/source_table.rb', line 21 def set_value_converters(converter_hash) @value_converters ||= {} # for backward compatibility with an old marshal dump object @columns.each_with_index do |(k, v), i| type = v[:format_type] if converter_hash.has_key?(type) @value_converters[i] = converter_hash[type] end end end |