Class: Walkon::EntranceMusic

Inherits:
Object
  • Object
show all
Defined in:
lib/walkon/entrance_music.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(with_file_name) ⇒ EntranceMusic

Returns a new instance of EntranceMusic.



7
8
9
# File 'lib/walkon/entrance_music.rb', line 7

def initialize with_file_name
  @filename = "#{prefix}/#{with_file_name}.mp3"
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



5
6
7
# File 'lib/walkon/entrance_music.rb', line 5

def filename
  @filename
end

Instance Method Details

#exists?Boolean Also known as: present?

Returns:

  • (Boolean)


11
12
13
# File 'lib/walkon/entrance_music.rb', line 11

def exists?
  File.exists? filename
end

#playObject



17
18
19
# File 'lib/walkon/entrance_music.rb', line 17

def play
  present? and play_track
end

#play_trackObject



21
22
23
# File 'lib/walkon/entrance_music.rb', line 21

def play_track
  `xmms #{filename}` == ''
end

#prefixObject



25
26
27
28
29
30
31
# File 'lib/walkon/entrance_music.rb', line 25

def prefix
  if Walkon.env == 'test'
    File.expand_path "../../../spec/fixtures/music", __FILE__
  else
    "/music"
  end
end