Class: MikePlayer::Settings
- Inherits:
-
Object
- Object
- MikePlayer::Settings
- 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
-
#minutes ⇒ Object
readonly
Returns the value of attribute minutes.
-
#music_dir ⇒ Object
readonly
Returns the value of attribute music_dir.
-
#playlist ⇒ Object
readonly
Returns the value of attribute playlist.
-
#random ⇒ Object
readonly
Returns the value of attribute random.
-
#volume ⇒ Object
readonly
Returns the value of attribute volume.
Instance Method Summary collapse
- #debug? ⇒ Boolean
-
#initialize(options) ⇒ Settings
constructor
A new instance of Settings.
- #list? ⇒ Boolean
- #overwrite? ⇒ Boolean
- #random? ⇒ Boolean
- #shuffle? ⇒ Boolean
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() @shuffle = [:shuffle] @overwrite = [:overwrite] @list = [:list] @home = [:home] || Dir.home @volume = [:volume] || DEFAULT_VOLUME @music_dir = [:directory] || File.join(@home, DEFAULT_DIRECTORY) @settings_dir = [:settings] || File.join(@home, SETTINGS_DIRECTORY) @minutes = [:minutes].to_i @debug = [:debug] @random = [:random].to_i if (false == Dir.exist?(@settings_dir)) Dir.mkdir(@settings_dir) end @playlist = find_playlist([:playlist]) remove_playlist_if_needed(@playlist) end |
Instance Attribute Details
#minutes ⇒ Object (readonly)
Returns the value of attribute minutes.
8 9 10 |
# File 'lib/mikeplayer/settings.rb', line 8 def minutes @minutes end |
#music_dir ⇒ Object (readonly)
Returns the value of attribute music_dir.
8 9 10 |
# File 'lib/mikeplayer/settings.rb', line 8 def music_dir @music_dir end |
#playlist ⇒ Object (readonly)
Returns the value of attribute playlist.
8 9 10 |
# File 'lib/mikeplayer/settings.rb', line 8 def playlist @playlist end |
#random ⇒ Object (readonly)
Returns the value of attribute random.
8 9 10 |
# File 'lib/mikeplayer/settings.rb', line 8 def random @random end |
#volume ⇒ Object (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
39 40 41 |
# File 'lib/mikeplayer/settings.rb', line 39 def debug? return (true == @debug) end |
#list? ⇒ Boolean
47 48 49 |
# File 'lib/mikeplayer/settings.rb', line 47 def list? return true == @list end |
#overwrite? ⇒ Boolean
43 44 45 |
# File 'lib/mikeplayer/settings.rb', line 43 def overwrite? return true == @overwrite end |
#random? ⇒ Boolean
35 36 37 |
# File 'lib/mikeplayer/settings.rb', line 35 def random? return 0 < @random end |
#shuffle? ⇒ Boolean
31 32 33 |
# File 'lib/mikeplayer/settings.rb', line 31 def shuffle? return true == @shuffle end |