Class: Net::DAAP::Song

Inherits:
Object
  • Object
show all
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



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

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.



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

def album
  @album
end

#artistObject (readonly)

Returns the value of attribute artist.



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

def artist
  @artist
end

#formatObject (readonly)

Returns the value of attribute format.



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

def format
  @format
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#nameObject (readonly) Also known as: to_s

Returns the value of attribute name.



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

def name
  @name
end

#persistentidObject (readonly)

Returns the value of attribute persistentid.



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

def persistentid
  @persistentid
end

#sizeObject (readonly)

Returns the value of attribute size.



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

def size
  @size
end

Instance Method Details

#get(&block) ⇒ Object

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



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

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