Class: Audiothority::Extract
- Inherits:
-
Object
- Object
- Audiothority::Extract
- Defined in:
- lib/audiothority/extract.rb
Instance Method Summary collapse
- #as_tags(paths, options = {}) ⇒ Object
-
#initialize(file_ref = TagLib::FileRef) ⇒ Extract
constructor
A new instance of Extract.
Constructor Details
#initialize(file_ref = TagLib::FileRef) ⇒ Extract
Returns a new instance of Extract.
8 9 10 |
# File 'lib/audiothority/extract.rb', line 8 def initialize(file_ref=TagLib::FileRef) @file_ref = file_ref end |
Instance Method Details
#as_tags(paths, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/audiothority/extract.rb', line 12 def (paths, ={}) file_refs = paths.map { |p| @file_ref.new(p.to_s, false) } null_refs = file_refs.select(&:null?) if null_refs.any? file_refs = file_refs - null_refs null_refs.each(&:close) end if file_refs.empty? return end yield file_refs.map(&:tag) ensure if file_refs file_refs.each(&:save) if [:save] file_refs.each(&:close) end end |