class MultimediaParadise::Audio::NAudioSongs

Constants

ALSO_STORE_FULL_PATHNAME_TO_THE_SONGS
#

ALSO_STORE_FULL_PATHNAME_TO_THE_SONGS

If the following constant is true, then we will also append all songs via comment.

#
ARRAY_AUDIO_FILES
#

ARRAY_AUDIO_FILES

#
AUDIO_DIR
#

AUDIO_DIR

#
NAMESPACE
#

NAMESPACE

#
STORE_HERE
#

STORE_HERE

#

Public Class Methods

[](i = '') click to toggle source
#

MultimediaParadise::Audio::NAudioSongs[]

#
# File lib/multimedia_paradise/audio/n_audio_songs.rb, line 208
def self.[](i = '')
  new(i)
end
new( i = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/multimedia_paradise/audio/n_audio_songs.rb, line 60
def initialize(
    i           = nil,
    run_already = true
  )
  reset
  set_input(i)
  run if run_already
end

Public Instance Methods

all_songs?() click to toggle source
#

all_songs?

This method will return all songs, as Array.

#
# File lib/multimedia_paradise/audio/n_audio_songs.rb, line 125
def all_songs?
  all_local_audio_songs = Dir["#{directory_to_the_local_songs?}*"].select {|entry| is_audio_song?(entry) }
  all_local_audio_songs = sort_array_alphabetically(
    all_local_audio_songs
  )
  return all_local_audio_songs
end
append(this) click to toggle source
#

append (append tag)

#
# File lib/multimedia_paradise/audio/n_audio_songs.rb, line 171
def append(this)
  case this
  when :comment
    this = '# '+('=' * 76)+' #'
  end
  @string_to_store << "#{this}#{N}" # Has a mandatory newline.
end
assemble_string_to_store() click to toggle source
#

assemble_string_to_store

#
# File lib/multimedia_paradise/audio/n_audio_songs.rb, line 182
def assemble_string_to_store
  @string_to_store = "#{n_songs_available} Songs - #{get_date}".dup
end
determine_how_many_songs_we_have() click to toggle source
#

determine_how_many_songs_we_have

#
# File lib/multimedia_paradise/audio/n_audio_songs.rb, line 107
def determine_how_many_songs_we_have
  files = Dir["#{AUDIO_DIR}/*"]
  @n_songs = files.reject {|entry| ! is_audio_song?(entry) }
  return @n_songs
end
do_save_all_the_necessary_parts() click to toggle source
#

do_save_all_the_necessary_parts

#
# File lib/multimedia_paradise/audio/n_audio_songs.rb, line 145
def do_save_all_the_necessary_parts
  if ALSO_STORE_FULL_PATHNAME_TO_THE_SONGS
    append ''
    append ''
    append '#'
    _ = ''.dup
    all_songs?.each {|this_song|
      _ << "# #{this_song}#{N}"
    }
    append _.chomp
    append '#'
  end
  save_file(@string_to_store, STORE_HERE)
end
get_date() click to toggle source
#

get_date

#
# File lib/multimedia_paradise/audio/n_audio_songs.rb, line 189
def get_date # This will return something like 'Jul 2013'
  Time.now.strftime('%d.%m.%Y')+
  ' ('+Time.now.strftime('%d')+' '+
  Date::MONTHNAMES[Date.today.month][0,3]+' '+Date.today.year.to_s+')'
end
input?() click to toggle source
#

input?

#
# File lib/multimedia_paradise/audio/n_audio_songs.rb, line 100
def input?
  @input
end
n_songs_available() click to toggle source
#

n_songs_available

#
# File lib/multimedia_paradise/audio/n_audio_songs.rb, line 116
def n_songs_available
  @n_songs.size.to_s
end
notify_the_user_what_will_be_done() click to toggle source
#

notify_the_user_what_will_be_done

#
# File lib/multimedia_paradise/audio/n_audio_songs.rb, line 163
def notify_the_user_what_will_be_done
  opnn; e "Now storing into #{sfile(STORE_HERE)} that there are"
  opnn; e sfancy(n_songs_available)+' songs available.'
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method MultimediaParadise::AudioBase#reset
# File lib/multimedia_paradise/audio/n_audio_songs.rb, line 72
def reset
  super()
  # ======================================================================= #
  # === @namespace
  # ======================================================================= #
  @namespace = NAMESPACE
  # ======================================================================= #
  # === @n_songs
  # ======================================================================= #
  @n_songs = 0
  # ======================================================================= #
  # === @string_to_store
  # ======================================================================= #
  @string_to_store = ''.dup
end
run() click to toggle source
#

run (run tag)

#
# File lib/multimedia_paradise/audio/n_audio_songs.rb, line 198
def run
  determine_how_many_songs_we_have
  assemble_string_to_store
  notify_the_user_what_will_be_done
  do_save_all_the_necessary_parts
end
set_input(i = '') click to toggle source
#

set_input

#
# File lib/multimedia_paradise/audio/n_audio_songs.rb, line 91
def set_input(i = '')
  i = i.first if i.is_a? Array
  i = i.to_s.dup
  @input = i
end
sort_array_alphabetically(array) click to toggle source
#

sort_array_alphabetically

#
# File lib/multimedia_paradise/audio/n_audio_songs.rb, line 136
def sort_array_alphabetically(array)
  return array.sort_by {|entry|
    File.basename(entry)
  }
end