Class: Scrobble::Track

Inherits:
Base
  • Object
show all
Defined in:
lib/scrobble/track.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

get_and_parse

Instance Attribute Details

#albumObject

FIXME: We really want this to be attr_reader, but new_from_element needs to write. Perhaps emulate Rails’ ability to pass a block.



4
5
6
# File 'lib/scrobble/track.rb', line 4

def album
  @album
end

#artistObject

FIXME: We really want this to be attr_reader, but new_from_element needs to write. Perhaps emulate Rails’ ability to pass a block.



4
5
6
# File 'lib/scrobble/track.rb', line 4

def artist
  @artist
end

#nameObject

FIXME: We really want this to be attr_reader, but new_from_element needs to write. Perhaps emulate Rails’ ability to pass a block.



4
5
6
# File 'lib/scrobble/track.rb', line 4

def name
  @name
end

#now_playingObject

Returns the value of attribute now_playing.



5
6
7
# File 'lib/scrobble/track.rb', line 5

def now_playing
  @now_playing
end

Class Method Details

.new_from_element(element, doc) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/scrobble/track.rb', line 7

def self.new_from_element( element, doc )
	t = Track.new

	t.now_playing = !!element[ "nowplaying" ]
	t.name = (element/"name").inner_text
	t.artist = (element/"artist").inner_text
	t.album = (element/"album").inner_text
	
	t
end

Instance Method Details

#now_playing?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/scrobble/track.rb', line 19

def now_playing?
	now_playing
end