Class: Fias::Import::Copy
- Inherits:
-
Object
- Object
- Fias::Import::Copy
- Defined in:
- lib/fias/import/copy.rb
Instance Attribute Summary collapse
-
#dbf ⇒ Object
readonly
Returns the value of attribute dbf.
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
Instance Method Summary collapse
- #copy ⇒ Object
- #encode ⇒ Object
-
#initialize(db, table_name, dbf, types = {}) ⇒ Copy
constructor
A new instance of Copy.
Constructor Details
#initialize(db, table_name, dbf, types = {}) ⇒ Copy
Returns a new instance of Copy.
6 7 8 9 10 11 12 13 |
# File 'lib/fias/import/copy.rb', line 6 def initialize(db, table_name, dbf, types = {}) @db = db @table_name = table_name.to_sym @dbf = dbf @encoder = PgDataEncoder::EncodeForCopy.new( column_types: map_types(types) ) end |
Instance Attribute Details
#dbf ⇒ Object (readonly)
Returns the value of attribute dbf.
4 5 6 |
# File 'lib/fias/import/copy.rb', line 4 def dbf @dbf end |
#table_name ⇒ Object (readonly)
Returns the value of attribute table_name.
4 5 6 |
# File 'lib/fias/import/copy.rb', line 4 def table_name @table_name end |
Instance Method Details
#copy ⇒ Object
23 24 25 26 |
# File 'lib/fias/import/copy.rb', line 23 def copy prepare copy_into end |
#encode ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/fias/import/copy.rb', line 15 def encode @dbf.each do |record| line = record.to_a.map { |v| v == '' ? nil : v } @encoder.add(line) yield if block_given? end end |