1
0
mirror of https://github.com/danbee/mpd-client synced 2025-03-04 08:39:09 +00:00
mpd-client/models/album.rb
2013-09-02 14:40:39 +01:00

27 lines
512 B
Ruby

require './models/mpd_connection'
class Album
attr_accessor :title, :genre, :year
def initialize(album)
first_song = MPDConnection.mpd.search(:album, album).first
@title = first_song.album
@genre = first_song.genre
@year = first_song.date
end
def self.by_artist(artist)
MPDConnection.mpd.albums(artist).map { |album| Album.new(album) }
end
def <=>(album)
year <=> album.year
end
def attributes
{ title: @title,
genre: @genre,
year: @year }
end
end