Class: LastfmM3u::FileSearch

Inherits:
Search show all
Defined in:
lib/lastfm-m3u/search/file_search.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#m3u, #m3u_path

Instance Method Summary collapse

Constructor Details

#initialize(root_dir) ⇒ FileSearch

Returns a new instance of FileSearch.



11
12
13
14
# File 'lib/lastfm-m3u/search/file_search.rb', line 11

def initialize(root_dir)
  @root_dir = Pathname root_dir
  super()
end

Instance Attribute Details

#root_dirObject

Returns the value of attribute root_dir.



9
10
11
# File 'lib/lastfm-m3u/search/file_search.rb', line 9

def root_dir
  @root_dir
end

Instance Method Details

#find(query, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/lastfm-m3u/search/file_search.rb', line 16

def find(query, options={})
  query_type  = options[:query_type] || :track
  file_or_id3 = options[:search_type] || :both
  prefer_flac = options[:prefer_flac] || true

  files = find_unique_files(query, query_type, file_or_id3)
  if prefer_flac
    files = flac_files(files) || files
  end
  $logger.debug "#{query} => #{files}"
  files
end