Class: AutoTune::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/autotune/util.rb

Constant Summary collapse

ITUNES_TAG_KEYS =
Array.new.push('artistId', 'collectionId', 'trackId', 'artistName',
'collectionName', 'trackName', 'artworkUrl100',
'releaseDate', 'collectionExplicitness',
'trackExplicitness', 'discCount', 'discNumber',
'trackCount', 'trackNumber', 'trackTimeMillis',
'country', 'currency', 'primaryGenreName')

Class Method Summary collapse

Class Method Details

.osObject



31
32
33
34
35
36
37
38
# File 'lib/autotune/util.rb', line 31

def self.os
  case RUBY_PLATFORM
    when /darwin|mac os/
      return 'macos'
    else
      raise SystemCallError.new('Operating System is not supported', 1)
  end
end

.parse(result_hash, track_number) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/autotune/util.rb', line 18

def self.parse(result_hash, track_number)
  (0..result_hash['resultCount'].to_i).each { |key|
    itunes_track_number = result_hash.dig('results', key, 'trackNumber')
    if track_number == itunes_track_number.to_i
      info = Array.new
      (0..ITUNES_TAG_KEYS.length).each { |index|
        info.push(result_hash.dig('results', key, ITUNES_TAG_KEYS[index]))
      }
      return info
    end
  }
end

.paths(directory) ⇒ Object



14
15
16
# File 'lib/autotune/util.rb', line 14

def self.paths(directory)
  Array.new(Find.find(directory).select { |p| /.*\.M4A$/i =~ p })
end