Class: WhosDatedWho::Importer

Inherits:
Object
  • Object
show all
Includes:
RethinkDB::Shortcuts
Defined in:
lib/whos_dated_who/importer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db, table_name) ⇒ Importer



6
7
8
9
10
# File 'lib/whos_dated_who/importer.rb', line 6

def initialize(db, table_name)
  @conn       = r.connect(host: 'localhost', db: db || 'celebs')
  @logger     = Logger.new(STDOUT)
  @table_name = table_name
end

Instance Attribute Details

#connObject (readonly)

Returns the value of attribute conn.



4
5
6
# File 'lib/whos_dated_who/importer.rb', line 4

def conn
  @conn
end

#loggerObject (readonly)

Returns the value of attribute logger.



4
5
6
# File 'lib/whos_dated_who/importer.rb', line 4

def logger
  @logger
end

#table_nameObject (readonly)

Returns the value of attribute table_name.



4
5
6
# File 'lib/whos_dated_who/importer.rb', line 4

def table_name
  @table_name
end

Instance Method Details

#fetch_and_import(celebs) ⇒ Object



12
13
14
15
16
17
# File 'lib/whos_dated_who/importer.rb', line 12

def fetch_and_import(celebs)
  celebs.each do |celeb|
    logger.info "Fetching #{celeb}"
    import_celeb(celeb)
  end
end