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
30
# 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
  @fullscreen = options[:fullscreen]

  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)


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

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

#fullscreen?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/mikeplayer/settings.rb', line 52

def fullscreen?
  return true == @fullscreen
end

#list?Boolean

Returns:

  • (Boolean)


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

def list?
  return true == @list
end

#overwrite?Boolean

Returns:

  • (Boolean)


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

def overwrite?
  return true == @overwrite
end

#random?Boolean

Returns:

  • (Boolean)


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

def random?
  return 0 < @random
end

#shuffle?Boolean

Returns:

  • (Boolean)


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

def shuffle?
  return true == @shuffle
end