class AudioStream::CLI

Public Instance Methods

banner() click to toggle source
time() click to toggle source
# File lib/audiostream/cli.rb, line 32
def time

  help(:time) if options[:playlist].nil?
  @filepath = "#{options[:playlist]}"
  
  if File.exists?(@filepath) then
    File.open(@filepath).each do |item|
      @item=item.chomp

      next if /^#EXT(M3U|INF:).*$/.match(@item)
      if File.exists?(@item) then
        @total_time << playtime(@item)
        puts "#{@item}: #{playtime(@item)}"
      else
        puts "Error: File #{@item} not found"
      end
    end
  else
    puts "Playlist could not be loaded."
  end
end
version() click to toggle source
# File lib/audiostream/cli.rb, line 25
def version
    puts AudioStream::VERSION
end

Private Instance Methods

playtime(path) click to toggle source
# File lib/audiostream/cli.rb, line 56
def playtime(path)
  Time.at(mp3(path).length).gmtime.strftime('%R:%S')
end