class MultimediaParadise::PlayFromThisList

Constants

NAMESPACE
#

NAMESPACE

#

Public Class Methods

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

MultimediaParadise::PlayFromThisList[]

#
# File lib/multimedia_paradise/multimedia/play_from_this_list.rb, line 146
def self.[](i = '')
  new(i)
end
new( commandline_arguments = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/multimedia_paradise/multimedia/play_from_this_list.rb, line 33
def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Public Instance Methods

commandline_arguments?() click to toggle source
#

commandline_arguments?

#
# File lib/multimedia_paradise/multimedia/play_from_this_list.rb, line 70
def commandline_arguments?
  @commandline_arguments
end
determine_from_which_list_to_play() click to toggle source
#

determine_from_which_list_to_play

#
# File lib/multimedia_paradise/multimedia/play_from_this_list.rb, line 77
def determine_from_which_list_to_play
  first = @commandline_arguments.first
  if first
    if first.is_a? String
      # =================================================================== #
      # In this case assume the user did input a list.
      # =================================================================== #
      @dataset = first
    elsif File.exist? first
      @dataset = File.readlines(first)
    end
    try_to_sanitize_the_dataset
  end
end
play_the_files_in_the_dataset() click to toggle source
#

play_the_files_in_the_dataset

#
# File lib/multimedia_paradise/multimedia/play_from_this_list.rb, line 117
def play_the_files_in_the_dataset
  if @dataset.nil? or @dataset.empty?
    opnn; e 'No valid input has been given to this class.'
  else
    @dataset.each {|entry| play_this_file(entry) }
  end
end
play_this_file(i) click to toggle source
#

play_this_file

#
# File lib/multimedia_paradise/multimedia/play_from_this_list.rb, line 128
def play_this_file(i)
  if i.include? "'"
    i = '"'+i+'"'
  end
  esystem "#{MultimediaParadise.use_this_player} #{i}"
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method MultimediaParadise::Base#reset
# File lib/multimedia_paradise/multimedia/play_from_this_list.rb, line 47
def reset
  super()
  # ======================================================================= #
  # === @namespace
  # ======================================================================= #
  @namespace = NAMESPACE
  # ======================================================================= #
  # === @dataset
  # ======================================================================= #
  @dataset = nil
end
run() click to toggle source
#

run (run tag)

#
# File lib/multimedia_paradise/multimedia/play_from_this_list.rb, line 138
def run
  determine_from_which_list_to_play
  play_the_files_in_the_dataset
end
set_commandline_arguments(i = '') click to toggle source
#

set_input

#
# File lib/multimedia_paradise/multimedia/play_from_this_list.rb, line 62
def set_commandline_arguments(i = '')
  i = [i].flatten.compact
  @commandline_arguments = i
end
try_to_sanitize_the_dataset() click to toggle source
#

try_to_sanitize_the_dataset

#
# File lib/multimedia_paradise/multimedia/play_from_this_list.rb, line 95
def try_to_sanitize_the_dataset
  if @dataset.is_a? String
    @dataset = @dataset.split(N).reject {|line|
      line.strip.empty?
    }
  end
  # ======================================================================= #
  # Past this point we assume to only have an Array. Sanitize this
  # Array further:
  # ======================================================================= #
  @dataset.map! {|entry|
    entry.strip!
    if entry.start_with? '- '
      entry[0,2] = ''
    end
    entry.strip
  }
end