Class: RJL::Album

Inherits:
Object
  • Object
show all
Defined in:
lib/rjl/album.rb

Overview

Represents an album in Apple’s ‘iTunes’ application.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tracks: []) ⇒ Album

Creates a new RJL::Album. Album properties are derived from the properties of the supplied tracks.

Parameters:

  • tracks (List of Track) (defaults to: [])

    the album tracks



13
14
15
# File 'lib/rjl/album.rb', line 13

def initialize( tracks: [])
  @tracks = tracks
end

Instance Attribute Details

#album_artistString artist name, String 'Various Artists' (readonly)

Album’s artist e.g “Simply Red”. Returns ‘Various Artists’ if more than one.

Returns:

  • (String artist name)

    the album artist if only one

  • (String 'Various Artists')

    if more than one



20
21
22
# File 'lib/rjl/album.rb', line 20

def album_artist
  @album_artist
end

#genreString

Album genre e.g “Pop/Rock [Alternative/Indie Rock]”

Returns:

  • (String)

    album genre



38
39
40
# File 'lib/rjl/album.rb', line 38

def genre
  @genre
end

#titleString (readonly)

Album title e.g “Greatest Hits”

Returns:

  • (String)

    album title



32
33
34
# File 'lib/rjl/album.rb', line 32

def title
  @title
end

#tracksList of Track (readonly)

The tracks in the album

Returns:

  • (List of Track)

    tracks the album tracks



57
58
59
# File 'lib/rjl/album.rb', line 57

def tracks
  @tracks
end

Instance Method Details

#protected?Boolean

Is the album protected from changes?

Returns:

  • (Boolean)

    true if it is



63
64
65
66
67
68
69
70
71
72
# File 'lib/rjl/album.rb', line 63

def protected?
  protected = false
  @tracks.each do |track|
    if track.tags.include? 'protected'
      protected = true
      break
    end
  end
  return protected
end

#to_sObject



74
75
76
77
78
79
80
81
# File 'lib/rjl/album.rb', line 74

def to_s
  puts "-"*50
  puts "> #{self.album_artist}, '#{self.title}'"
  @tracks.each do |track|
    puts "  #{track.name}"
  end
  puts "="*50
end