Method: Core::Song#initialize

Defined in:
lib/song.rb

#initialize(file) ⇒ Song

Returns a new instance of Song.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/song.rb', line 7

def initialize(file)
  @file = file
  if @@cache[file]
    @song = @@cache[file]
    return
  end
  begin
    @song = Gosu::Song.new(Core.window, "#{Core::LIBRARY_PATH}/music/#{file}.mp3")
    @@cache.store(file, @song)
  rescue RuntimeError
    puts("ERROR: Failed to open music #{file}")
    return
  end
end