Class: MPD::Song
- Inherits:
-
Hash
- Object
- Hash
- MPD::Song
- Defined in:
- lib/mpd/song.rb
Overview
Hash with predefined structure (see MAPPINGS) created from basic MPD song info Additionaly it stores base data via #data
Constant Summary collapse
- MAPPINGS =
{ file: 'file', artist: 'Artist', album: 'Album', title: 'Title', year: 'Date', genre: 'Genre', id: 'Id', position: 'Pos', time: 'Time' }.freeze
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(data) ⇒ Song
constructor
A new instance of Song.
Constructor Details
#initialize(data) ⇒ Song
Returns a new instance of Song.
18 19 20 21 22 |
# File 'lib/mpd/song.rb', line 18 def initialize(data) super() @data = data MAPPINGS.each { |key, data_key| self[key] = data[data_key] } end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
16 17 18 |
# File 'lib/mpd/song.rb', line 16 def data @data end |