Class: Gdshowsdb::SongDBExtractor

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(songs) ⇒ SongDBExtractor

Returns a new instance of SongDBExtractor.



7
8
9
# File 'lib/gdshowsdb/song_db_extractor.rb', line 7

def initialize(songs)
  @songs = songs
end

Class Method Details

.from_db(year) ⇒ Object



3
4
5
# File 'lib/gdshowsdb/song_db_extractor.rb', line 3

def self.from_db(year)      
  SongDBExtractor.new(Song.find_all_by_year(year))
end

Instance Method Details

#extractObject



11
12
13
14
15
16
17
18
19
# File 'lib/gdshowsdb/song_db_extractor.rb', line 11

def extract
  @songs.map do |song|
    song_map = song.attributes.convert_to_sym
    song_map[:name] = song.song_ref.name if song.song_ref
    song_map.reject {|k,v| k == :song_ref_uuid }
  end.reject do |song_map|
    song_map[:name].nil?
  end
end