Class: MPD::Controller::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/mpd/controller/status.rb

Defined Under Namespace

Classes: Mixer, Playlist

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller) ⇒ Status

Returns a new instance of Status.



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
45
46
47
48
49
50
51
52
53
# File 'lib/mpd/controller/status.rb', line 20

def initialize (controller)
	@controller = controller

	@mixer    = Mixer.new
	@playlist = Playlist.new

	controller.do_and_raise_if_needed(:status).each {|name, value|
		case name
		when :state          then @status           = value
		when :repeat         then @repeat           = value
		when :random         then @random           = value
		when :single         then @single           = value
		when :consume        then @consume          = value
		when :volume         then @volume           = value
		when :xfade          then @crossfade        = value
		when :mixrampdb      then @mixer.decibels   = value
		when :mixrampdelay   then @mixer.delay      = value
		when :bitrate        then @bitrate          = value
		when :error          then @error            = value
		when :playlist       then @playlist.version = value
		when :playlistlength then @playlist.length  = value

		when :song    then (@playlist.current ||= Playlist::Song.new).position = value
		when :songid  then (@playlist.current ||= Playlist::Song.new).id       = value
		when :time    then (@playlist.current ||= Playlist::Song.new).elapsed  = value
		when :elapsed then (@playlist.current ||= Playlist::Song.new).elapsed  = value

		when :nextsong   then (@playlist.next ||= Playlist::Song.new).position = value
		when :nextsongid then (@playlist.next ||= Playlist::Song.new).id       = value
		end
	}

	@song = Database::Song.from_data(controller.do_and_raise_if_needed(:currentsong))
end

Instance Attribute Details

#bitrateObject (readonly)

Returns the value of attribute bitrate.



18
19
20
# File 'lib/mpd/controller/status.rb', line 18

def bitrate
  @bitrate
end

#controllerObject (readonly)

Returns the value of attribute controller.



18
19
20
# File 'lib/mpd/controller/status.rb', line 18

def controller
  @controller
end

#crossfadeObject (readonly)

Returns the value of attribute crossfade.



18
19
20
# File 'lib/mpd/controller/status.rb', line 18

def crossfade
  @crossfade
end

#errorObject (readonly)

Returns the value of attribute error.



18
19
20
# File 'lib/mpd/controller/status.rb', line 18

def error
  @error
end

#mixerObject (readonly)

Returns the value of attribute mixer.



18
19
20
# File 'lib/mpd/controller/status.rb', line 18

def mixer
  @mixer
end

#playlistObject (readonly)

Returns the value of attribute playlist.



18
19
20
# File 'lib/mpd/controller/status.rb', line 18

def playlist
  @playlist
end

#songObject (readonly)

Returns the value of attribute song.



18
19
20
# File 'lib/mpd/controller/status.rb', line 18

def song
  @song
end

#volumeObject (readonly)

Returns the value of attribute volume.



18
19
20
# File 'lib/mpd/controller/status.rb', line 18

def volume
  @volume
end

Instance Method Details

#==(other) ⇒ Object



60
61
62
# File 'lib/mpd/controller/status.rb', line 60

def == (other)
	super || to_sym.downcase == other.to_sym.downcase
end

#consume?Boolean

Returns:

  • (Boolean)


58
# File 'lib/mpd/controller/status.rb', line 58

def consume?; @consume; end

#random?Boolean

Returns:

  • (Boolean)


56
# File 'lib/mpd/controller/status.rb', line 56

def random?;  @random; end

#repeat?Boolean

Returns:

  • (Boolean)


55
# File 'lib/mpd/controller/status.rb', line 55

def repeat?;  @repeat; end

#single?Boolean

Returns:

  • (Boolean)


57
# File 'lib/mpd/controller/status.rb', line 57

def single?;  @single; end

#to_symObject



64
65
66
# File 'lib/mpd/controller/status.rb', line 64

def to_sym
	@status
end