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

Returns a new instance of Song.



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

def initialize(args)
  info = args[:song_info]
  @size           = info['daap.songsize']
  @album          = info['daap.songalbum']
  @name           = info['dmap.itemname']
  @artist         = info['daap.songartist']
  @format         = info['daap.songformat']
  @persistentid   = info['dmap.persistentid']
  @id             = info['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)

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

#getObject

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



21
22
23
24
# File 'lib/net/daap/song.rb', line 21

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