Sha256: 36f3d8cb1b92280133ca0ca671ec07f96f49c7c0eeab2c6da9768f5547b19bda

Contents?: true

Size: 564 Bytes

Versions: 2

Compression:

Stored size: 564 Bytes

Contents

module ItunesParser
  module Track

    # Shows all tracks in the doc.
    # Returns Hash { track_id => { <track_information> } }
    # Optional param `pretty` returns Array of Hashes with only IDs and Names.
    def tracks pretty: false
      _tracks = doc["Tracks"]

      unless pretty
        _tracks
      else
        _tracks.collect{|track| { id: track[1]["Track ID"], name: track[1]["Name"] }}
      end
    end

    # Shows one track.
    # Returns Hash with track info.
    def track(id)
      tracks.select{|pl| pl["#{id}"] }.first[1]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
itunes_parser-1.1.1 lib/itunes_parser/track.rb
itunes_parser-1.1.0 lib/itunes_parser/track.rb