Class: FreeZipcodeData::DbTable

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

Direct Known Subclasses

CountryTable, CountyTable, StateTable, ZipcodeTable

Constant Summary collapse

ISSUE_URL =
'https://github.com/midwire/free_zipcode_data/issues/new'
@@progressbar =
nil

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database:, tablename:) ⇒ DbTable

Returns a new instance of DbTable.



13
14
15
16
17
18
# File 'lib/free_zipcode_data/db_table.rb', line 13

def initialize(database:, tablename:)
  @database  = database
  @tablename = tablename
  lc = select_first('SELECT value FROM meta where name = "line_count"')
  @@progressbar = ProgressBar.create(total: lc.to_i * 4, format: '%t: |%B| %e')
end

Instance Attribute Details

#databaseObject (readonly)

Returns the value of attribute database.



10
11
12
# File 'lib/free_zipcode_data/db_table.rb', line 10

def database
  @database
end

#tablenameObject (readonly)

Returns the value of attribute tablename.



10
11
12
# File 'lib/free_zipcode_data/db_table.rb', line 10

def tablename
  @tablename
end

Instance Method Details

#update_progressObject



20
21
22
# File 'lib/free_zipcode_data/db_table.rb', line 20

def update_progress
  @@progressbar.increment
end