Property definitions

mpd $ ServerStatus :: defaultinit
# MPD server status
class ServerStatus

	# MPD server volume.
	var volume: nullable Int

	# Playback state (play/stop/pause).
	var state: String

	# Is MPD server playing?
	fun playing: Bool do return state == "play"

	# Is MPD server stopped?
	fun stopped: Bool do return state == "stop"

	# Time elapsed within the current song.
	var elapsed: nullable Int

	# TODO comment
	var time_at: nullable Int

	# Total time of the current song.
	var time_total: nullable Int

	# Get the cursor position on the song duration.
	fun time_ratio: nullable Float do
		if time_at == null or time_total == null then return null
		return time_at.to_f / time_total.to_f
	end

	redef fun to_s do
		var vol = "unknown"
		if volume != null then vol = volume.to_s

		var time_at = time_at
		var time_total = time_total
		var elapsed = elapsed
		if time_at != null and time_total != null and elapsed != null then
			return "volume: {vol}\nstate: {state}\nelapsed: {elapsed}\ntime_[at|total]: {time_at}:{time_total}\ntime_ratio: {time_ratio.as(not null)}"
		else
			return "volume: {vol}\nstate: {state}"
		end
	end
end
lib/mpd/mpd.nit:214,1--257,3