class MultimediaParadise::Base
Constants
- N
#¶ ↑
N
¶ ↑#¶ ↑
- NAMESPACE
#¶ ↑
NAMESPACE
¶ ↑#¶ ↑
- USE_THIS_NAMESPACE_FOR_THE_COLOURS
#¶ ↑
USE_THIS_NAMESPACE_FOR_THE_COLOURS
¶ ↑Add a “pointer” to the colours gem, via its namespace “Colours”.
#¶ ↑
Public Class Methods
Public Instance Methods
#¶ ↑
be_silent
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/base/misc.rb, line 208 def be_silent @be_verbose = false end
#¶ ↑
be_verbose?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/base/misc.rb, line 194 def be_verbose? @be_verbose end
#¶ ↑
beautiful_url
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/base/misc.rb, line 579 def beautiful_url(i) unless Object.const_defined? :BeautifulUrl begin require 'beautiful_url' rescue LoadError; end end i = ::BeautifulUrl.new(i) if Object.const_defined? :BeautifulUrl i = i.first if i.is_a? Array return i end
#¶ ↑
cartoons_directory?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/base/misc.rb, line 331 def cartoons_directory? MultimediaParadise.cartoons_directory? end
#¶ ↑
cd (cd tag)¶ ↑
#¶ ↑
# File lib/multimedia_paradise/base/misc.rb, line 236 def cd(i) ::MultimediaParadise.chdir(i) end
#¶ ↑
commandline_arguments?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/base/commandline_arguments.rb, line 28 def commandline_arguments? @commandline_arguments end
#¶ ↑
commandline_arguments_as_a_string
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/base/commandline_arguments.rb, line 35 def commandline_arguments_as_a_string @commandline_arguments.join(' ').strip end
#¶ ↑
dd_mm_yyyy
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/base/time.rb, line 14 def dd_mm_yyyy return ::Time.now.strftime('%d.%m.%Y') end
#¶ ↑
directory_to_realvids?¶ ↑
This method will return the absolute path to my local realvid directory.
It is only used in code of classes that deal with my local multimedia files really.
#¶ ↑
# File lib/multimedia_paradise/base/misc.rb, line 310 def directory_to_realvids? ::MultimediaParadise.realvids_directory? end
#¶ ↑
does_the_video_player_support_this_commandline?¶ ↑
The following method checks whether the chosen video player at hand supports a particular commandline. The check is necessary because on some systems ‘mpv’ may be an alias to ‘mplayer.
#¶ ↑
# File lib/multimedia_paradise/base/misc.rb, line 63 def does_the_video_player_support_this_commandline?( this_commandline = '--msg-color' ) cmd = ::MultimediaParadise.use_which_video_player?+ ' '+this_commandline.strip+' 2>&1' result = `#{cmd}` !result.include?('Unknown option on the command line: ') end
#¶ ↑
ensure_main_encoding
¶ ↑
This method can ensure that a String has the proper encoding that we will use for the MultimediaParadise
project.
#¶ ↑
# File lib/multimedia_paradise/base/encoding.rb, line 19 def ensure_main_encoding( i, use_this_encoding = USE_THIS_ENCODING ) if i.is_a? String unless i.encoding.to_s.include? use_this_encoding i = i.dup if i.frozen? i = i.force_encoding(use_this_encoding) end end i end
#¶ ↑
ensure_that_the_output_directory_exists
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/base/misc.rb, line 558 def ensure_that_the_output_directory_exists( this_dir = log_directory? ) this_dir = File.dirname(this_dir) unless this_dir.end_with? '/' ::MultimediaParadise.ensure_that_the_output_directory_exists end
#¶ ↑
first_argument?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/base/commandline_arguments.rb, line 14 def first_argument? @commandline_arguments.first end
#¶ ↑
hh_mm_ss
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/base/time.rb, line 21 def hh_mm_ss return ::Time.now.strftime('%H:%M:%S') end
#¶ ↑
infer_the_namespace
¶ ↑
This will assume the true namespace from the inspectable name.
#¶ ↑
# File lib/multimedia_paradise/base/namespace.rb, line 21 def infer_the_namespace _ = inspect if _.include?(':0x') _ = _.split(':0x').first.to_s.strip end _ = _.to_s.delete('<') if _.include? ' ' _ = _.split(' ').first.delete('#') if _.include? ':' _ = _.split(':')[0 .. -2].reject {|entry| entry.empty? }.join('::') end end @namespace = _.delete('#') # And assign it here. end
#¶ ↑
is_audio_file?¶ ↑
This method can be used in order to determine whether we are working with an audio file here or whether we are not.
#¶ ↑
# File lib/multimedia_paradise/base/misc.rb, line 279 def is_audio_file?(i) ::MultimediaParadise.is_audio_file?(i) end
#¶ ↑
is_multimedia_file?¶ ↑
This method will return true if the given directory is either an audio file or a video file.
#¶ ↑
# File lib/multimedia_paradise/base/misc.rb, line 571 def is_multimedia_file?(i) is_audio_file?(i) or is_video_file?(i) end
#¶ ↑
is_video_file?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/base/misc.rb, line 478 def is_video_file?(i) ::MultimediaParadise.is_video_file?(i) # Delegate to the module-method here. end
#¶ ↑
local_audio_directory?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/base/misc.rb, line 317 def local_audio_directory? MultimediaParadise.local_audio_directory? end
#¶ ↑
log_dir?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/base/misc.rb, line 551 def log_dir? ::MultimediaParadise.log_dir? end
#¶ ↑
map_symbol_to_locally_existing_file
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/base/misc.rb, line 338 def map_symbol_to_locally_existing_file(i) case i # case tag # ======================================================================= # # === wrap :beauty # ======================================================================= # when :beauty, ':beauty', :american_beauty, ':american_beauty' i = "#{realvids_directory?}017_American_Beauty.mp4" # ======================================================================= # # === wrap :halloween # ======================================================================= # when :halloween, ':halloween' i = "#{realvids_directory?}215_Halloween.mp4" # ======================================================================= # # === wrap :predator # ======================================================================= # when :predator, ':predator' i = "#{realvids_directory?}245_Predator.avi" else e 'Unhandled symbol: '+i.to_s end i end
#¶ ↑
opnn¶ ↑
#¶ ↑
# File lib/multimedia_paradise/base/misc.rb, line 260 def opnn( namespace = { namespace: @namespace }, &block ) # ======================================================================= # # Turn a String into a Hash next. # ======================================================================= # if namespace.is_a? String namespace = { namespace: namespace } # Use the input to the method in this case. end Opn.opn(namespace, &block) end
#¶ ↑
register_sigint
¶ ↑
If an argument is passed to this method then it will be displayed.
#¶ ↑
# File lib/multimedia_paradise/base/misc.rb, line 595 def register_sigint( use_this_as_exit_message = 'Exiting now as requested.', &block ) clear_kde_konsole_tab_on_exit = false # ======================================================================= # # === Handle blocks given to this method next # ======================================================================= # if block_given? yielded = yield case yielded # ===================================================================== # # === :clear_kde_konsole_tab_on_exit_if_is_on_roebe # ===================================================================== # when :clear_kde_konsole_tab_on_exit_if_is_on_roebe, :pretty if is_on_roebe? clear_kde_konsole_tab_on_exit = true end end end Signal.trap('SIGINT') { e use_this_as_exit_message if use_this_as_exit_message if clear_kde_konsole_tab_on_exit begin require 'roebe/classes/kde/kde_konsole/kde_konsole.rb' e Roebe.konsole_tab_title('.') # Rename the tab again. rescue LoadError; end end exit } end
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
# File lib/multimedia_paradise/base/misc.rb, line 89 def reset # ======================================================================= # # === @use_colours # ======================================================================= # @use_colours = true # ======================================================================= # # === @be_verbose # ======================================================================= # set_be_verbose # ======================================================================= # # === @debug # # By default, debugging is disabled. # ======================================================================= # @debug = false end
#¶ ↑
return_random_video
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/base/misc.rb, line 505 def return_random_video unless ::MultimediaParadise.respond_to? :return_random_video require 'multimedia_paradise/toplevel_methods/return_random_video_file_from_the_video_collection.rb' end ::MultimediaParadise.return_random_video end
#¶ ↑
save_what_into
¶ ↑
A simple wrapper over SaveFile.
#¶ ↑
# File lib/multimedia_paradise/base/misc.rb, line 517 def save_what_into(what, into) if Object.const_defined? :SaveFile SaveFile.write_what_into(what, into) end end
#¶ ↑
try_to_rename_kde_konsole_tab
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/base/misc.rb, line 464 def try_to_rename_kde_konsole_tab( new_title = '_', try_to_rename_the_kde_konsole_tab = TRY_TO_RENAME_THE_KDE_KONSOLE_TAB ) MultimediaParadise.try_to_rename_kde_konsole_tab( new_title, try_to_rename_the_kde_konsole_tab ) end