Class: Sox::Command::Playlist
- Inherits:
-
Object
- Object
- Sox::Command::Playlist
- Defined in:
- lib/sox/command.rb
Instance Attribute Summary collapse
-
#inputs ⇒ Object
Returns the value of attribute inputs.
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
- #file ⇒ Object
-
#initialize(inputs) ⇒ Playlist
constructor
A new instance of Playlist.
- #path ⇒ Object
- #useful? ⇒ Boolean
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
#inputs ⇒ Object
Returns the value of attribute inputs.
108 109 110 |
# File 'lib/sox/command.rb', line 108 def inputs @inputs end |
Instance Method Details
#create ⇒ Object
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 |
#delete ⇒ Object
132 133 134 135 136 137 |
# File 'lib/sox/command.rb', line 132 def delete if @file @file.close(true) @file = nil end end |
#file ⇒ Object
114 115 116 |
# File 'lib/sox/command.rb', line 114 def file @file ||= Tempfile.new(['sox-command-playlist','.m3u']) end |
#path ⇒ Object
118 119 120 |
# File 'lib/sox/command.rb', line 118 def path file.path end |
#useful? ⇒ Boolean
139 140 141 142 |
# File 'lib/sox/command.rb', line 139 def useful? inputs.all? { |input| input..empty? } and inputs.sum { |i| i.filename.size } > 500 end |