Class: Sox::Command::Playlist

Inherits:
Object
  • Object
show all
Defined in:
lib/sox/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(inputs) ⇒ Playlist

Returns a new instance of Playlist.



110
111
112
# File 'lib/sox/command.rb', line 110

def initialize(inputs)
  @inputs = inputs
end

Instance Attribute Details

#inputsObject

Returns the value of attribute inputs.



108
109
110
# File 'lib/sox/command.rb', line 108

def inputs
  @inputs
end

Instance Method Details

#createObject



122
123
124
125
126
127
128
129
130
# File 'lib/sox/command.rb', line 122

def create
  ::File.open(file.path,"w") do |playlist|
    inputs.each do |input|
      playlist.puts input.filename
    end
  end

  file.path
end

#deleteObject



132
133
134
135
136
137
# File 'lib/sox/command.rb', line 132

def delete
  if @file
    @file.close(true)
    @file = nil
  end
end

#fileObject



114
115
116
# File 'lib/sox/command.rb', line 114

def file
  @file ||= Tempfile.new(['sox-command-playlist','.m3u'])
end

#pathObject



118
119
120
# File 'lib/sox/command.rb', line 118

def path
  file.path
end

#useful?Boolean

Returns:

  • (Boolean)


139
140
141
142
# File 'lib/sox/command.rb', line 139

def useful?
  inputs.all? { |input| input.options.empty? } and
    inputs.sum { |i| i.filename.size } > 500
end