Class: MikePlayer::Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/mikeplayer/settings.rb

Constant Summary collapse

DEFAULT_DIRECTORY =
'Music'.freeze
DEFAULT_VOLUME =
'0.1'
SETTINGS_DIRECTORY =
'.mikeplayer'.freeze
PL_FILE_ENDING =
'.mpl'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Settings

Returns a new instance of Settings.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mikeplayer/settings.rb', line 10

def initialize(options)
  @shuffle   = options[:shuffle]
  @overwrite = options[:overwrite]
  @list      = options[:list]
  @home      = options[:home] || Dir.home
  @volume    = options[:volume] || DEFAULT_VOLUME
  @music_dir = options[:directory] || File.join(@home, DEFAULT_DIRECTORY)
  @settings_dir = options[:settings] || File.join(@home, SETTINGS_DIRECTORY)
  @minutes   = options[:minutes].to_i
  @debug     = options[:debug]
  @random    = options[:random].to_i

  if (false == Dir.exist?(@settings_dir))
    Dir.mkdir(@settings_dir)
  end

  @playlist  = find_playlist(options[:playlist])

  remove_playlist_if_needed(@playlist)
end

Instance Attribute Details

#minutesObject (readonly)

Returns the value of attribute minutes.



8
9
10
# File 'lib/mikeplayer/settings.rb', line 8

def minutes
  @minutes
end

#music_dirObject (readonly)

Returns the value of attribute music_dir.



8
9
10
# File 'lib/mikeplayer/settings.rb', line 8

def music_dir
  @music_dir
end

#playlistObject (readonly)

Returns the value of attribute playlist.



8
9
10
# File 'lib/mikeplayer/settings.rb', line 8

def playlist
  @playlist
end

#randomObject (readonly)

Returns the value of attribute random.



8
9
10
# File 'lib/mikeplayer/settings.rb', line 8

def random
  @random
end

#volumeObject (readonly)

Returns the value of attribute volume.



8
9
10
# File 'lib/mikeplayer/settings.rb', line 8

def volume
  @volume
end

Instance Method Details

#debug?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/mikeplayer/settings.rb', line 39

def debug?
  return (true == @debug)
end

#list?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/mikeplayer/settings.rb', line 47

def list?
  return true == @list
end

#overwrite?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/mikeplayer/settings.rb', line 43

def overwrite?
  return true == @overwrite
end

#random?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/mikeplayer/settings.rb', line 35

def random?
  return 0 < @random
end

#shuffle?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/mikeplayer/settings.rb', line 31

def shuffle?
  return true == @shuffle
end