Class: MPD::Song

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

Instance Method Summary collapse

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

#dataObject (readonly)

Returns the value of attribute data


16
17
18
# File 'lib/mpd/song.rb', line 16

def data
  @data
end