Class: MPD::Protocol::Response::Data

Inherits:
Object
  • Object
show all
Defined in:
lib/mpd/protocol/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value) ⇒ Data

Returns a new instance of Data.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/mpd/protocol/response.rb', line 19

def initialize (name, value)
	@name  = name
	@value = case name
	when :song, :artists, :albums, :songs, :uptime, :playtime, :db_playtime, :volume,
	     :playlistlength, :xfade, :Time, :Pos, :Id, :Date, :Track, :Disc, :MUSICBRAINZ_TRACKID,
	     :MUSICBRAINZ_ARTISTID, :MUSICBRAINZ_ALBUMID, :MUSICBRAINZ_ALBUMARTISTID, :outputid
		value.to_i

	when :mixrampdb, :mixrampdelay
		value == 'nan' ? Float::NAN : value.to_f

	when :repeat, :random, :single, :consume, :outputenabled
		value != '0'

	when :db_update
		Time.at(value.to_i)

	when :command, :state, :changed, :replay_gain_mode
		value.to_sym

	when :"Last-Modified"
		DateTime.iso8601(value)

	else value.force_encoding('UTF-8')
	end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



17
18
19
# File 'lib/mpd/protocol/response.rb', line 17

def name
  @name
end

#valueObject (readonly)

Returns the value of attribute value.



17
18
19
# File 'lib/mpd/protocol/response.rb', line 17

def value
  @value
end