Class: MultimediaParadise::Audio::NAudioSongs
Overview
Constant Summary
collapse
- STORE_HERE =
"#{AUDIO_DIRECTORY}README.md"
- AUDIO_DIR =
ENV['MY_SONGS'].to_s
- ARRAY_AUDIO_FILES =
%w(
mp3 ogg
)
- 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.
#
true
Constants inherited
from Base
Base::ERROR, Base::ERROR_LINE, Base::NAMESPACE, Base::USE_THIS_NAMESPACE_FOR_THE_COLOURS, Base::USE_THIS_NAMESPACE_FOR_THE_CORE_COLOURS
Class Method Summary
collapse
Instance Method Summary
collapse
#directory_to_the_local_songs?, #return_random_audio_file
Methods inherited from Base
#actions, #append_what_into, #be_silent, #be_verbose?, #beautiful_url, #cartoons_directory?, #clear_the_internal_hash, #cliner, #cliner_with_time_stamp, #colourized_comment, #copy_file, #crimson, #dataset_from_file_video_collection, #dd_mm_yyyy, #debug?, #default_readlines, #directory_to_realvids?, #do_not_use_opn, #dodgerblue, #does_the_video_player_support_this_commandline?, #e, #ecomment, #ecrimson, #efancy, #enable_debug, #ensure_main_encoding, #ensure_that_the_output_directory_exists, #eparse, #erev, #esystem, #ewarn, #file_video_collection?, #filter_for_audio_files, #filter_for_video_files, #forestgreen, #gold, #grey, #hh_mm_ss, #home_x_video?, #indianred, #infer_the_namespace, #internal_hash?, #is_audio_file?, #is_mkv?, #is_mp3?, #is_mp4?, #is_multimedia_file?, #is_on_roebe?, #is_video_file?, #konsole_colour_peru, #lightblue, #lightgreen, #load_yaml, #local_audio_directory?, #log_dir?, #map_symbol_to_locally_existing_file, #mediumorchid, #mediumpurple, #mediumslateblue, #mkdir, #move_file, #namespace?, #no_file_exists, #no_file_exists_at, #olive, #olivedrab, #opne, #opnecomment, #opnn, #orange, #palegoldenrod, #palegreen, #powderblue, #project_base_directory?, #rds, #register_sigint, #remove_file, #report_pwd, #reset_the_internal_hash, #return_all_video_files, #return_pwd, #return_random_video, #rev, #royalblue, #save_what_into, #sdir, #seagreen, #seconds_to_time_format, #select_only_video_files_from, #set_be_verbose, #set_use_colours, #sfancy, #sfile, #simp, #skyblue, #slateblue, #springgreen, #steelblue, #swarn, #teal, #time_right_now, #to_hh_mm_ss, #tomato, #true_rev, #try_to_rename_kde_konsole_tab, #ucliner, #use_colours?, #use_opn?, #use_which_video_player?, #verbose_truth, #video_collection?, #violet, #yaml_directory?, #yel
#all_input_starts_with_a_number?, #commandline_arguments?, #commandline_arguments_as_a_string, #first_argument?, #first_non_hyphened_commandline_argument?, #set_commandline_arguments
Constructor Details
#initialize(i = nil, run_already = true) ⇒ NAudioSongs
56
57
58
59
60
61
62
63
|
# File 'lib/multimedia_paradise/audio/n_audio_songs.rb', line 56
def initialize(
i = nil,
run_already = true
)
reset
set_input(i)
run if run_already
end
|
Class Method Details
.[](i = '') ⇒ Object
201
202
203
|
# File 'lib/multimedia_paradise/audio/n_audio_songs.rb', line 201
def self.[](i = '')
new(i)
end
|
Instance Method Details
#all_songs? ⇒ Boolean
#
all_songs?
This method will return all songs, as Array.
#
118
119
120
121
122
123
124
|
# File 'lib/multimedia_paradise/audio/n_audio_songs.rb', line 118
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) ⇒ Object
164
165
166
167
168
169
170
|
# File 'lib/multimedia_paradise/audio/n_audio_songs.rb', line 164
def append(this)
case this
when :comment
this = '# '+('=' * 76)+' #'
end
@string_to_store << "#{this}#{N}" end
|
#assemble_string_to_store ⇒ Object
#
assemble_string_to_store
#
175
176
177
|
# File 'lib/multimedia_paradise/audio/n_audio_songs.rb', line 175
def assemble_string_to_store
@string_to_store = "#{n_songs_available} Songs - #{get_date}".dup
end
|
#determine_how_many_songs_we_have ⇒ Object
#
determine_how_many_songs_we_have
#
100
101
102
103
104
|
# File 'lib/multimedia_paradise/audio/n_audio_songs.rb', line 100
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 ⇒ Object
#
do_save_all_the_necessary_parts
#
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
# File 'lib/multimedia_paradise/audio/n_audio_songs.rb', line 138
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 ⇒ Object
182
183
184
185
186
|
# File 'lib/multimedia_paradise/audio/n_audio_songs.rb', line 182
def get_date Time.now.strftime('%d.%m.%Y')+
' ('+Time.now.strftime('%d')+' '+
Date::MONTHNAMES[Date.today.month][0,3]+' '+Date.today.year.to_s+')'
end
|
93
94
95
|
# File 'lib/multimedia_paradise/audio/n_audio_songs.rb', line 93
def input?
@input
end
|
#n_songs_available ⇒ Object
109
110
111
|
# File 'lib/multimedia_paradise/audio/n_audio_songs.rb', line 109
def n_songs_available
@n_songs.size.to_s
end
|
#notify_the_user_what_will_be_done ⇒ Object
#
notify_the_user_what_will_be_done
#
156
157
158
159
|
# File 'lib/multimedia_paradise/audio/n_audio_songs.rb', line 156
def notify_the_user_what_will_be_done
opne "#{rev}Now storing into #{sfile(STORE_HERE)} #{rev}that there are"
opne "#{sfancy(n_songs_available)}#{rev} songs available."
end
|
#reset ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/multimedia_paradise/audio/n_audio_songs.rb', line 68
def reset
super()
infer_the_namespace
@n_songs = 0
@string_to_store = ''.dup
end
|
#run ⇒ Object
191
192
193
194
195
196
|
# File 'lib/multimedia_paradise/audio/n_audio_songs.rb', line 191
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
|
84
85
86
87
88
|
# File 'lib/multimedia_paradise/audio/n_audio_songs.rb', line 84
def set_input(i = '')
i = i.first if i.is_a? Array
i = i.to_s.dup
@input = i
end
|
#sort_array_alphabetically(array) ⇒ Object
#
sort_array_alphabetically
#
129
130
131
132
133
|
# File 'lib/multimedia_paradise/audio/n_audio_songs.rb', line 129
def sort_array_alphabetically(array)
return array.sort_by {|entry|
File.basename(entry)
}
end
|