Class: Net::DAAP::Song

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/net/daap/song.rb

Overview

This class contains song information returned from the DAAP server.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Song

Returns a new instance of Song.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/net/daap/song.rb', line 10

def initialize(args)
  @size           = args['daap.songsize']
  @album          = args[:album]
  @name           = args['dmap.itemname']
  #@artist         = args['daap.songartist']
  @artist         = args[:artist]
  @format         = args['daap.songformat']
  @persistentid   = args['dmap.persistentid']
  @id             = args['dmap.itemid']
  @daap           = args[:daap]
  @db             = args[:db]
end

Instance Attribute Details

#albumObject (readonly)

Returns the value of attribute album.



6
7
8
# File 'lib/net/daap/song.rb', line 6

def album
  @album
end

#artistObject (readonly)

Returns the value of attribute artist.



6
7
8
# File 'lib/net/daap/song.rb', line 6

def artist
  @artist
end

#formatObject (readonly)

Returns the value of attribute format.



6
7
8
# File 'lib/net/daap/song.rb', line 6

def format
  @format
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/net/daap/song.rb', line 6

def id
  @id
end

#nameObject (readonly) Also known as: to_s

Returns the value of attribute name.



6
7
8
# File 'lib/net/daap/song.rb', line 6

def name
  @name
end

#persistentidObject (readonly)

Returns the value of attribute persistentid.



6
7
8
# File 'lib/net/daap/song.rb', line 6

def persistentid
  @persistentid
end

#sizeObject (readonly)

Returns the value of attribute size.



6
7
8
# File 'lib/net/daap/song.rb', line 6

def size
  @size
end

Instance Method Details

#<=>(other) ⇒ Object



29
30
31
# File 'lib/net/daap/song.rb', line 29

def <=>(other)
  name <=> other.name
end

#get(&block) ⇒ Object

Fetches the song data from the DAAP server and returns it.



24
25
26
27
# File 'lib/net/daap/song.rb', line 24

def get(&block)
  filename = "#{@id}.#{@format}"
  @daap.get_song("databases/#{@db.id}/items/#{filename}", &block)
end