Class: MPD::Controller::Stickers::Element

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/mpd/controller/stickers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stickers, type, uri) ⇒ Element

Returns a new instance of Element.



47
48
49
50
51
# File 'lib/mpd/controller/stickers.rb', line 47

def initialize (stickers, type, uri)
	@stickers = stickers
	@type     = type
	@uri      = uri
end

Instance Attribute Details

#stickersObject (readonly)

Returns the value of attribute stickers.



45
46
47
# File 'lib/mpd/controller/stickers.rb', line 45

def stickers
  @stickers
end

#typeObject (readonly)

Returns the value of attribute type.



45
46
47
# File 'lib/mpd/controller/stickers.rb', line 45

def type
  @type
end

#uriObject (readonly)

Returns the value of attribute uri.



45
46
47
# File 'lib/mpd/controller/stickers.rb', line 45

def uri
  @uri
end

Instance Method Details

#[](name) ⇒ Object



53
54
55
# File 'lib/mpd/controller/stickers.rb', line 53

def [] (name)
	find { |s| s.name == name.to_s }
end

#delete(name) ⇒ Object



57
58
59
# File 'lib/mpd/controller/stickers.rb', line 57

def delete (name)
	self[name].delete! rescue nil
end

#eachObject



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/mpd/controller/stickers.rb', line 61

def each
	return to_enum unless block_given?

	@stickers.controller.do_and_raise_if_needed(:sticker, :list, type, uri).each {|_, sticker|
		name, value = sticker.split '=', 2

		yield Sticker.new(self, name)
	}

	self
end