Class: Audioscrobbler::SubmissionQueue::PlayedTrack
- Inherits:
-
Object
- Object
- Audioscrobbler::SubmissionQueue::PlayedTrack
- Defined in:
- lib/audioscrobbler.rb
Overview
A track that’s been played.
Instance Attribute Summary collapse
-
#album ⇒ Object
readonly
Returns the value of attribute album.
-
#artist ⇒ Object
readonly
Returns the value of attribute artist.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#mbid ⇒ Object
readonly
Returns the value of attribute mbid.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#track_num ⇒ Object
readonly
Returns the value of attribute track_num.
Class Method Summary collapse
-
.deserialize(str) ⇒ Object
Undo the operation performed by serialize(), returning a new PlayedTrack object (class method).
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(artist, title, length, start_time, album = "", mbid = "", track_num = nil) ⇒ PlayedTrack
constructor
constructor.
-
#serialize ⇒ Object
Convert this track’s information into a form suitable for writing to a text file.
Constructor Details
#initialize(artist, title, length, start_time, album = "", mbid = "", track_num = nil) ⇒ PlayedTrack
constructor
563 564 565 566 567 568 569 570 571 572 |
# File 'lib/audioscrobbler.rb', line 563 def initialize(artist, title, length, start_time, album="", mbid="", track_num=nil) @artist = artist.to_s @title = title.to_s @length = length.to_i @start_time = start_time.to_i @album = album ? album.to_s : "" @mbid = mbid ? mbid.to_s : "" @track_num = track_num ? track_num.to_s : "" end |
Instance Attribute Details
#album ⇒ Object (readonly)
Returns the value of attribute album.
573 574 575 |
# File 'lib/audioscrobbler.rb', line 573 def album @album end |
#artist ⇒ Object (readonly)
Returns the value of attribute artist.
573 574 575 |
# File 'lib/audioscrobbler.rb', line 573 def artist @artist end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
573 574 575 |
# File 'lib/audioscrobbler.rb', line 573 def length @length end |
#mbid ⇒ Object (readonly)
Returns the value of attribute mbid.
573 574 575 |
# File 'lib/audioscrobbler.rb', line 573 def mbid @mbid end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
573 574 575 |
# File 'lib/audioscrobbler.rb', line 573 def start_time @start_time end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
573 574 575 |
# File 'lib/audioscrobbler.rb', line 573 def title @title end |
#track_num ⇒ Object (readonly)
Returns the value of attribute track_num.
573 574 575 |
# File 'lib/audioscrobbler.rb', line 573 def track_num @track_num end |
Class Method Details
.deserialize(str) ⇒ Object
Undo the operation performed by serialize(), returning a new PlayedTrack object (class method).
592 593 594 595 |
# File 'lib/audioscrobbler.rb', line 592 def self.deserialize(str) PlayedTrack.new(*str.split("\t").collect {|x| x ? CGI.unescape(x) : "" }) end |
Instance Method Details
#==(other) ⇒ Object
597 598 599 600 601 602 |
# File 'lib/audioscrobbler.rb', line 597 def ==(other) other.class == PlayedTrack and @artist == other.artist and @title == other.title and @length == other.length and @start_time == other.start_time and @album == other.album and @mbid == other.mbid and @track_num == other.track_num end |
#serialize ⇒ Object
Convert this track’s information into a form suitable for writing to a text file. Returns a string.
580 581 582 583 584 |
# File 'lib/audioscrobbler.rb', line 580 def serialize parts = [@artist, @title, @length.to_s, @start_time.to_s, @album, @mbid, @track_num] parts.collect {|x| x ? CGI.escape(x) : "" }.join("\t") end |