class Artist

Attributes

name[RW]
songs[RW]

Public Class Methods

all() click to toggle source
# File lib/Hot_100_CLI/artist.rb, line 13
def self.all
  @@all
end
create_by_list_name(list_name) click to toggle source
# File lib/Hot_100_CLI/artist.rb, line 26
def self.create_by_list_name(list_name)
  artists = []
  list_name[:name].split(" Featuring ").map do |name|
    if name.include?(" & ")
      name.split(" & ").map do |name|
        artists << Artist.find_or_new_by_name(name)
      end
    else
      artists << Artist.find_or_new_by_name(name)
    end
  end
  artists
end
find_by_name(name) click to toggle source
# File lib/Hot_100_CLI/artist.rb, line 21
def self.find_by_name(name)
  all.detect { |artist| artist.name.downcase == name.downcase }
end
find_or_new_by_name(name) click to toggle source
# File lib/Hot_100_CLI/artist.rb, line 40
def self.find_or_new_by_name(name)
  if self.all.detect{ |song| song.name == name  }
    artist = self.all.detect{ |song| song.name == name  }
  else 
    artist = Artist.new(name)
    artist.save
  end
  artist
end
new(name) click to toggle source
# File lib/Hot_100_CLI/artist.rb, line 7
def initialize(name)
  @name = name
  @songs = []

end

Public Instance Methods

save() click to toggle source
# File lib/Hot_100_CLI/artist.rb, line 17
def save
  @@all << self
end